This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/10111: Parse error for default template parameter
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: <gcc-gnats at gcc dot gnu dot org>,<gcc-bugs at gcc dot gnu dot org>,<philippeb at videotron dot ca>,<nobody at gcc dot gnu dot org>,<gcc-prs at gcc dot gnu dot org>
- Date: Sun, 16 Mar 2003 21:04:09 +0100
- Subject: Re: c++/10111: Parse error for default template parameter
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