This is the mail archive of the gcc-bugs@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]

Re: c++/3638: [2003-01-02] Template class instanciated using wrong type


http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
r=3638

This bug is pratically the same of c++/10394, but it shows a wrong code
generation issue that was not noticed before:

--------------------------------------------------------------
#include <iostream>

using namespace std;

template <class _T> struct traits
{
    typedef long next;
};


template <class _T>
struct c1
{
    template <class _UUU>
    struct c2
    {
        c1 c;
    };

    c1()
    {
        cout << __PRETTY_FUNCTION__ << endl;
    }

};


template <class _T>
void foo()
{
    c1<typename traits<_T>::next>::c2<void>();
    typename c1<typename traits<_T>::next>::template c2<void>();
}


int main()
{
    foo<int>();
}
--------------------------------------------------------------

When executed on 3.2/3.3, this prints:

c1<_T>::c1() [with _T = int]
c1<_T>::c1() [with _T = long int]

when the type should obviously be the same. So it's a bug related to the
implicit typename/template keywords. It's fixed in 3.4 because implicit
typename/template are not allowed anymore, so the bug simply does not
happen. Moreover, it's not a regression because 2.95 was giving an ICE on
this code.

I guess this should be closed, unless we consider the code generation bug
serious enough to need a fix on the 3.3 branch.

Giovanni Bajo


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