This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52460] New: Misleading error message with templated c++ code
- From: "petschy at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 02 Mar 2012 09:04:48 +0000
- Subject: [Bug c++/52460] New: Misleading error message with templated c++ code
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52460
Bug #: 52460
Summary: Misleading error message with templated c++ code
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: petschy@gmail.com
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', hence the error
message is misleading.
I'm not sure, the above code is probably ill-formed, because it creates a
circular dependence between the two types, but then, this should be
communicated to the user.