I have the next sample code that compiles with gcc (4.7.2 using -std=c++11):
template<class C>
struct template_test
{
C testing() const
{
return C();
}
};
class A;
struct test : public template_test<A> // (1)
{};
struct A
{};
int main()
{
test t;
}
At point (1) the function template_test<A>::testing()
is instantiated, and use a function of A
, specifically its default constructor. Therefore, test
contains this instantiated function as a function member. However, at this point A
is an incomplete type, and C++ prohibits you to use members of a incomplete type.
Is this a positive
gcc's error or is there another explanation?