c++/3638: [2003-01-02] Template class instanciated using wrong type
Giovanni Bajo
giovannibajo@libero.it
Mon Apr 14 04:36:00 GMT 2003
The following reply was made to PR c++/3638; it has been noted by GNATS.
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>,
<gdr@gcc.gnu.org>,
<philippeb@videotron.ca>,
<gcc-prs@gcc.gnu.org>
Cc: "Wolfgang Bangerth" <bangerth@ices.utexas.edu>,
"Gabriel Dos Reis" <gdr@integrable-solutions.net>
Subject: Re: c++/3638: [2003-01-02] Template class instanciated using wrong type
Date: Mon, 14 Apr 2003 06:28:21 +0200
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
More information about the Gcc-prs
mailing list