public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/10111: Parse error for default template parameter
@ 2003-03-16 20:06 Giovanni Bajo
0 siblings, 0 replies; 4+ messages in thread
From: Giovanni Bajo @ 2003-03-16 20:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/10111; it has been noted by GNATS.
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>,
<philippeb@videotron.ca>,
<nobody@gcc.gnu.org>,
<gcc-prs@gcc.gnu.org>
Cc:
Subject: Re: c++/10111: Parse error for default template parameter
Date: Sun, 16 Mar 2003 21:04:09 +0100
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/10111: Parse error for default template parameter
@ 2003-03-18 0:08 bangerth
0 siblings, 0 replies; 4+ messages in thread
From: bangerth @ 2003-03-18 0:08 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, philippeb
Synopsis: Parse error for default template parameter
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Tue Mar 18 00:08:31 2003
State-Changed-Why:
Duplicate of PR 57. The code with parenthesis around the
default arg now compiles in mainline.
Previous versions of gcc gave a really unhelpful message
on it, funnily:
g/x> /home/bangerth/bin/gcc-3.3-pre/bin/c++ -c x.cc
x.cc:13: error: parse error before `;' token
Here is this part of the code:
-----------------
template <int I>
struct B
{
template <class T, class U, class V>
B (const A<T, U, V>&,
typename A<T, U, V>::I = (typename A<T, U, V>::I ()), // #13
typename A<T, U, V>::I = (A<T, U, V>::i)) { }
};
-----------------
There's not ; on line 13, or anywhere close to it...
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10111
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/10111: Parse error for default template parameter
@ 2003-03-17 0:06 Martin Sebor
0 siblings, 0 replies; 4+ messages in thread
From: Martin Sebor @ 2003-03-17 0:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/10111; it has been noted by GNATS.
From: Martin Sebor <sebor@roguewave.com>
To: gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: c++/10111: Parse error for default template parameter
Date: Sun, 16 Mar 2003 17:03:49 -0700
Giovanni Bajo wrote:
> 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.
Not necessarily. The issue is in Open state, so it's still a bug
at least until the next revision of C++ (assuming issue 325 is
accepted as a defect) :)
> 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)) {}
But this still doesn't seem to (at least not with 3.2.2).
Incidentally, this test case is isolated from std::bitset.
template <class T, class U, class V>
struct A
{
typedef int I;
static const I i = 0;
};
template <int I>
struct B
{
template <class T, class U, class V>
B (const A<T, U, V>&,
typename A<T, U, V>::I = (typename A<T, U, V>::I ()),
typename A<T, U, V>::I = (A<T, U, V>::i)) { }
};
int main ()
{
A<int, int, int> a;
B<0> b (a);
}
Regards
Martin
^ permalink raw reply [flat|nested] 4+ messages in thread
* c++/10111: Parse error for default template parameter
@ 2003-03-16 16:16 philippeb
0 siblings, 0 replies; 4+ messages in thread
From: philippeb @ 2003-03-16 16:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 10111
>Category: c++
>Synopsis: Parse error for default template parameter
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 16 16:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: gcc
>Release: 3.0.4
>Organization:
>Environment:
Debian GNU / Linux
>Description:
The default parameter of template type is generating a parse error.
>How-To-Repeat:
>Fix:
Write seperate member function with no default argument of this type.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="ice.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ice.cpp"
I2luY2x1ZGUgPGlvc3RyZWFtPgoKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoKdGVtcGxhdGUgPGNs
YXNzIFQsIGNsYXNzIFU+CglzdHJ1Y3QgdnQKCXsKCQlzdGF0aWMgaW50IHZhbHVlOwoJfTsKCnRl
bXBsYXRlIDxjbGFzcyBULCBjbGFzcyBVPgoJaW50IHZ0PFQsIFU+Ojp2YWx1ZTsKCgpzdHJ1Y3Qg
QQp7CglBKGludCAqIGFfcCA9ICYgdHlwZW5hbWUgdnQ8aW50LCBpbnQ+Ojp2YWx1ZSkge30KfTsK
CgppbnQgbWFpbigpCnsKCUEgYTsKfQo=
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-03-18 0:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-16 20:06 c++/10111: Parse error for default template parameter Giovanni Bajo
-- strict thread matches above, loose matches on Subject: below --
2003-03-18 0:08 bangerth
2003-03-17 0:06 Martin Sebor
2003-03-16 16:16 philippeb
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).