[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

G++ ICEs on invalid+confusing template member function definition



>Submitter-Id:	net
>Originator:	Andrew Sayers
>Organization:	
>Confidential:	no
>Synopsis:	G++ ICEs on invalid+confusing template member function definition
>Severity:	non-critical
>Priority:	low
>Category:	c++
>Class:		ice-on-illegal-code
>Release:	4.0.2 (Debian 4.0.1-9) (Debian testing/unstable)
>Environment:
System: Linux nautilus 2.6.12.3 #1 Fri Jul 29 13:43:06 BST 2005 i686 GNU/Linux
Architecture: i686

	
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
>Description:
The code presented below causes the following error:

template_error.cpp:8: internal compiler error: in check_classfn, at cp/decl2.c:615
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.0/README.Bugs>.

The function definition includes a template T, but is actually a specialisation that only applies to foo<int>.  Correcting foo<int> to foo<T> on line 8 causes GCC to compile correctly.

>How-To-Repeat:
gcc -lstdc++ template_error.cpp

Preprocessed source code:
# 1 "type_error.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "type_error.cpp"
template<class T>
class foo {
 template<class S>
 int bar(foo<S>);
};

template<class T> template<class S>
int foo<int>::bar(foo<S> s) {
 return 0;
};

int main() {
 return 0;
};
>Fix:
This error only occurs for illegal code.



Reply to: