This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/3638: Template class instanciated using wrong type
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/3638: Template class instanciated using wrong type
- From: philippeb at videotron dot ca
- Date: 10 Jul 2001 22:46:42 -0000
- Reply-To: philippeb at videotron dot ca
>Number: 3638
>Category: c++
>Synopsis: Template class instanciated using wrong type
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 10 15:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: g++ 3.0
>Release: 20010402 (Debian prerelease)
>Organization:
>Environment:
Debian i386
>Description:
The compiler is generating a nested template class using the wrong type. The attached program generates the following output:
1) void foo() [with _T = int]
2) c1<_T>::c1() [with _T = int]
3) c1<_T>::c1() [with _T = long int]
The second line should be the same as the 3rd line. I think the 'typename' keyword is problematic.
>How-To-Repeat:
>Fix:
Find a way not to use the 'typename' keyword.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="recursivetemplate.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="recursivetemplate.cpp"
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnRlbXBsYXRlIDxjbGFz
cyBfVD4gc3RydWN0IHRyYWl0cwp7Cgl0eXBlZGVmIGxvbmcgbmV4dDsKfTsKCgp0ZW1wbGF0ZSA8
Y2xhc3MgX1Q+CglzdHJ1Y3QgYzEKCXsKCQljMSgpCgkJewoJCQljb3V0IDw8IF9fUFJFVFRZX0ZV
TkNUSU9OX18gPDwgZW5kbDsKCQl9CgoJCXRlbXBsYXRlIDxjbGFzcyBfVT4KCQkJc3RydWN0IGMy
CgkJCXsKCQkJCWMxIGM7CgkJCX07Cgl9OwoKCnRlbXBsYXRlIDxjbGFzcyBfVD4KCXZvaWQgZm9v
KCkKCXsKCQljb3V0IDw8IF9fUFJFVFRZX0ZVTkNUSU9OX18gPDwgZW5kbDsKCQljMTx0eXBlbmFt
ZSB0cmFpdHM8X1Q+OjpuZXh0Pjo6YzI8dm9pZD4oKTsKCX0KCgppbnQgbWFpbigpCnsKCWZvbzxp
bnQ+KCk7CgljMTx0cmFpdHM8aW50Pjo6bmV4dD46OmMyPHZvaWQ+KCk7Cn0K