public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113812] New: Comma expression parsed as declaration when ambiguous type name cast is present
@ 2024-02-07 17:26 gabravier at gmail dot com
2024-02-07 17:30 ` [Bug c++/113812] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: gabravier at gmail dot com @ 2024-02-07 17:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113812
Bug ID: 113812
Summary: Comma expression parsed as declaration when ambiguous
type name cast is present
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
void f()
{
int(x), a, b, c, d, e, f, g, h, etc;
int(x), a, b, c, d, e, f, g, h, etc, (new int);
}
Clang parses this fine, but GCC errors out, complaining that:
<source>: In function 'void f()':
<source>:4:9: error: redeclaration of 'int x'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:9: note: 'int x' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:13: error: redeclaration of 'int a'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:13: note: 'int a' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:16: error: redeclaration of 'int b'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:16: note: 'int b' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:19: error: redeclaration of 'int c'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:19: note: 'int c' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:22: error: redeclaration of 'int d'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:22: note: 'int d' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:25: error: redeclaration of 'int e'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:25: note: 'int e' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:28: error: redeclaration of 'int f'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:28: note: 'int f' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:31: error: redeclaration of 'int g'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:31: note: 'int g' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:34: error: redeclaration of 'int h'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^
<source>:3:34: note: 'int h' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^
<source>:4:37: error: redeclaration of 'int etc'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^~~
<source>:3:37: note: 'int etc' previously declared here
3 | int(x), a, b, c, d, e, f, g, h, etc;
| ^~~
<source>:4:43: error: expected unqualified-id before 'new'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ^~~
<source>:4:43: error: expected ')' before 'new'
4 | int(x), a, b, c, d, e, f, g, h, etc, (new int);
| ~^~~
| )
It appears that GCC is treating the second statement in the function as a
declaration instead of a comma expression, which Clang does.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/113812] Comma expression parsed as declaration when ambiguous type name cast is present
2024-02-07 17:26 [Bug c++/113812] New: Comma expression parsed as declaration when ambiguous type name cast is present gabravier at gmail dot com
@ 2024-02-07 17:30 ` pinskia at gcc dot gnu.org
2024-02-07 17:33 ` gabravier at gmail dot com
2024-02-07 17:36 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-07 17:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113812
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect this is a dup of bug 29834.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/113812] Comma expression parsed as declaration when ambiguous type name cast is present
2024-02-07 17:26 [Bug c++/113812] New: Comma expression parsed as declaration when ambiguous type name cast is present gabravier at gmail dot com
2024-02-07 17:30 ` [Bug c++/113812] " pinskia at gcc dot gnu.org
@ 2024-02-07 17:33 ` gabravier at gmail dot com
2024-02-07 17:36 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: gabravier at gmail dot com @ 2024-02-07 17:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113812
--- Comment #2 from Gabriel Ravier <gabravier at gmail dot com> ---
Also I guess this is a simpler minimal example:
void f(int x)
{
int(x), 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/113812] Comma expression parsed as declaration when ambiguous type name cast is present
2024-02-07 17:26 [Bug c++/113812] New: Comma expression parsed as declaration when ambiguous type name cast is present gabravier at gmail dot com
2024-02-07 17:30 ` [Bug c++/113812] " pinskia at gcc dot gnu.org
2024-02-07 17:33 ` gabravier at gmail dot com
@ 2024-02-07 17:36 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-07 17:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113812
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes this is a dup of bug 29834.
*** This bug has been marked as a duplicate of bug 29834 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-07 17:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 17:26 [Bug c++/113812] New: Comma expression parsed as declaration when ambiguous type name cast is present gabravier at gmail dot com
2024-02-07 17:30 ` [Bug c++/113812] " pinskia at gcc dot gnu.org
2024-02-07 17:33 ` gabravier at gmail dot com
2024-02-07 17:36 ` pinskia at gcc dot gnu.org
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).