This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/1908: Member Template Specialization Bug
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/1908: Member Template Specialization Bug
- From: cjoy at houston dot rr dot com
- Date: 8 Feb 2001 05:54:15 -0000
- Cc: corwin dot joy at caminus dot com
- Reply-To: cjoy at houston dot rr dot com
>Number: 1908
>Category: c++
>Synopsis: Member Template Specialization Bug
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Wed Feb 07 21:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Corwin Joy
>Release: 2.96 20000731 and Code Sourcery Online Compile as of Feb 7, 2001
>Organization:
>Environment:
Red Hat Linux 7.0
>Description:
Attempting to specialize member templates in a class causes the compiler to crash. Attached example code compiles and specializes correctly in Visual Studio 97. Simple example attached is just standard member template specialization. See C++ ISO Standard 14882 (i.e. 1998 release) section 14.5.2 p. 247, section 5.
Here is the error message from Code Sourcery
These are the results of processing your source code with the following command:
g++ [input]
Exit code: 256
Messages:
/tmp/@14876.7.cc:10: explicit specialization in non-namespace scope `class foo'
/tmp/@14876.7.cc:10: invalid use of undefined type `class foo'
/tmp/@14876.7.cc:3: forward declaration of `class foo'
/tmp/@14876.7.cc:10: Internal error #19990331.
confused by earlier errors, bailing out
>How-To-Repeat:
Compile attached
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="main.cpp"
Content-Disposition: inline; filename="main.cpp"
#include <iostream.h>
class foo {
public:
template<typename T> void bar (T &t) {
cout << t << endl;
}
template<> void bar<double>(double &t) {
cout << "I am special : " << t << endl;
}
};
int main() {
foo f;
int i = 5;
double d = 3.14;
f.bar(i);
f.bar(d);
return 0;
}