This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/3638: [2003-01-02] Template class instanciated using wrong type
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: <gcc-gnats at gcc dot gnu dot org>,<gcc-bugs at gcc dot gnu dot org>,<gdr at gcc dot gnu dot org>,<philippeb at videotron dot ca>,<gcc-prs at gcc dot gnu dot org>
- Cc: "Wolfgang Bangerth" <bangerth at ices dot utexas dot edu>,"Gabriel Dos Reis" <gdr at integrable-solutions dot net>
- Date: Mon, 14 Apr 2003 06:28:21 +0200
- Subject: 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