public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55097] New: typedef not recognized in templated class
@ 2012-10-27 13:35 petschy at gmail dot com
  2012-10-27 13:43 ` [Bug c++/55097] [4.7/4.8 Regression] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: petschy at gmail dot com @ 2012-10-27 13:35 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-07 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-27 13:35 [Bug c++/55097] New: typedef not recognized in templated class petschy at gmail dot com
2012-10-27 13:43 ` [Bug c++/55097] [4.7/4.8 Regression] " redi at gcc dot gnu.org
2012-10-27 23:11 ` paolo.carlini at oracle dot com
2012-11-07 15:13 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).