This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Misleading error message with templated c++ code


Hello,

compiling the following:
---8<---8<---8<---8<---
template<typename T>
struct Base
{
        typename T::Type        var;
};
template<typename U>
struct Derived : Base<Derived<U> >
{
        typedef U       Type;
};
void foo()
{
        Derived<int> i;
}
---8<---8<---8<---8<---
gives the error

gcctempl.cpp: In instantiation of âstruct Base<Derived<int> >â:
gcctempl.cpp:7:8:   required from âstruct Derived<int>â
gcctempl.cpp:13:15:   required from here
gcctempl.cpp:4:19: error: no type named âTypeâ in âstruct Derived<int>â

on all tested gcc versions (4.4, 4.5, 4.6,4.7). There is definitely a type called 'Type' in struct 'Derived'. I'm not sure, the above code might be ill-formed, but then I'd like to see a specific error message.

Regards, Peter



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]