------- Comment #7 from reichelt at gcc dot gnu dot org 2005-11-17 15:23
-------
Giovanni's example now compiles on mainline and the 4.0 branch
due to Mark's patch for PR 23789:
==================================================
template <typename T, int I = int()> struct A {};
template <typename T> void foo(A<T>) {}
void bar()
{
foo(A<char>());
}
==================================================
However, I still get "sorry, unimplemented" for the following testcase
which is closer to the original one:
==================================================
template <typename T, T I = T()> struct A {};
template <typename T> void foo(A<T>) {}
void bar()
{
foo(A<char>());
}
==================================================
bug.cc: In function 'void foo(A<T, T()>) [with T = char]':
bug.cc:3: sorry, unimplemented: zero-operand casts cannot be mangled due to a
defect in the C++ ABI
Note that "T()" is not a cast, but a default-constructed object.
A related problem is shown by the following testcase:
==================================================
template<int> struct A {};
A<int()> a;
==================================================
bug.cc:3: error: type/value mismatch at argument 1 in template parameter list
for `template<int <anonymous> > struct A'
bug.cc:3: error: expected a constant of type `int', got `int ()()'
bug.cc:3: error: invalid type in declaration before ';' token
Obviously "int()" is not interpreted as "0", but as a function "int ()()".
Maybe "T()" in the example above causes the same problems.
Btw, icc compiles all testcases without problems.
--
reichelt at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mark at codesourcery dot com
Keywords|ice-on-valid-code |rejects-valid
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9436