c++/9436: passing a class template followed by a template value of this class

Giovanni Bajo giovannibajo@libero.it
Fri Jan 24 19:46:00 GMT 2003


http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
r=9436

Slightly reduced testcase:
-------------------------------
template <typename T, int P = int()>
struct A {};

template <typename T>
void foo(A<T> ) {}

void bar(void)
{
 A<char> a;
 foo(a);
}
-------------------------------
ice.cpp: In function `void bar()':
ice.cpp:12: internal error: Segmentation fault
Please submit a full bug report,

This shows that the bug has nothing to do with the dependency between the
first parameter and the second (default) parameter. GCC seems to crash
(segmentation fault) when trying to specialize the foo() function, and the
problem is that the default (and not explicitally matched) parameter P uses
a constructor as initializer. If you substitute 'int()' with 0, or you
explicitally match the full type by declaring the parameter of foo as
'A<T,0>', the ICE goes away. Not tested on post 3.2, might be fixed with the
new parser.

Giovanni Bajo



More information about the Gcc-bugs mailing list