[Bug c++/55097] New: typedef not recognized in templated class
petschy at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Oct 27 13:35:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55097
Bug #: 55097
Summary: typedef not recognized in templated class
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: petschy@gmail.com
gcc 4.7 and 4.8 chokes on the following code:
----8<----8<----8<----8<----8<----8<----8<----
class Id
{
public:
Id();
Id(char a, char b);
explicit Id(int v);
Id(const char* id_);
};
template<typename ID>
class Foo
{
public:
// typedef ID IdType;
void Bar(const ID& id_);
typedef ID IdType;
};
template<typename ID>
void Foo<ID>::Bar(const IdType& id_)
//void Foo<ID>::Bar(const ID& id_)
{
}
void foo()
{
Foo<Id> f;
f.Bar("hello");
}
----8<----8<----8<----8<----8<----8<----8<----
$ g++ -c gcctypedef.cpp
gcctypedef.cpp: In function ‘void foo()’:
gcctypedef.cpp:29:15: error: no matching function for call to
‘Foo<Id>::Bar(const char [6])’
gcctypedef.cpp:29:15: note: candidate is:
gcctypedef.cpp:21:6: note: void Foo<ID>::Bar(const IdType&) [with ID = Id;
Foo<ID>::IdType = Id]
gcctypedef.cpp:21:6: note: no known conversion for argument 1 from ‘const
char [6]’ to ‘Id&’
Earlier versions are ok, clang 3.0 also compiles the code.
If the typedef in class Foo is _before_ the Bar fn declaration, gcc compiles
the code.
If instead of the typedef (IdType) the original type (ID) is used in the
argument of the Bar fn at the definition, gcc compiles the code.
I git bisect'd the commit that introduced the bug:
commit 44f861fca343148a1b0720105ec2b7f14bbcc849
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed Feb 8 09:52:11 2012 +0000
PR c++/52035
* pt.c (tsubst): Strip uninstantiated typedef.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184000
138bc75d-0d04-0410-961f-82ee72b054a4
More information about the Gcc-bugs
mailing list