c++/10111: Parse error for default template parameter
Giovanni Bajo
giovannibajo@libero.it
Sun Mar 16 20:16:00 GMT 2003
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
r=10111
Not a real bug. All boils down to a definition like this:
void Foo(int a = A<int,int>::something) {}
There is an open defect report about this
(http://www.comeaucomputing.com/iso/cwg_active.html#325), because (shortly)
ISO C++ does not mandate that the compiler must understand that the comma is
separating template parameters, and not parameters of the function you are
declaring. Simple workaround is putting a couple of paranthesis around the
default argument, the code will compile correctly:
void Foo(int a = (A<int,int>::something)) {}
Notice that both Comeau and VC7.1 accepts this syntax right now, maybe it
could be worth considering adding it as an "extension" to the mainline. I
think it's common sense that the code should work.
(Another little note is that the code, as submitted, is ill-formed, typename
may not be used outside template definitions).
Giovanni Bajo
More information about the Gcc-bugs
mailing list