This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Misleading error message with templated c++ code
- From: "Peter A. Felvegi" <petschy at praire-chicken dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 03 Feb 2012 22:28:44 +0100
- Subject: 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