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]

Regression/bug in 4.7 regarding typedef in templated class


Hello,

after upgrading gcc one of my classes failed to compile. Stock Debian/Wheezy 4.4, 4.5, 4.6 compiled the code, also compiled a version of 4.7.0 that was built by me from sources some time ago. Clang 3.0-6 also compiled, but stock 4.7.1-7, the head of 4.7 (4.7.3 d51dc77f, r192839) and the head of master (4.8.0 1a2798ac, r192875) didn't.

Reduced the code to a test case:

----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&â


4.8 gives the same error, but in prettier, more verbose format.

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 regression/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

I didn't find anything relevant in Bugzilla when searching for 'typedef template'. Should I file a bug report?

Kind regards, Peter



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