public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37213] New: Declaration/expression ambiguity resolution does not extend beyond initializer
@ 2008-08-23 20:18 akyrtzi at gmail dot com
2008-08-24 22:30 ` [Bug c++/37213] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: akyrtzi at gmail dot com @ 2008-08-23 20:18 UTC (permalink / raw)
To: gcc-bugs
When compiling the following program:
struct S {int z;};
typedef S* (*FuncType)(int,int);
int x,y;
S* a() {
FuncType(a)(x,y)->z = 0; // treated as declaration
return 0;
}
This is the result:
t.cpp: In function 'S* a()':
t.cpp:5: error: initializer expression list treated as compound expression
t.cpp:5: error: invalid conversion from 'int' to 'S* (*)(int, int)'
t.cpp:5: error: expected ',' or ';' before '->' token
Shouldn't GCC examine '->' after 'FuncType(a)(x,y)' and conclude that the
statement is an expression instead of a declaration ?
--
Summary: Declaration/expression ambiguity resolution does not
extend beyond initializer
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: akyrtzi at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37213
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/37213] Declaration/expression ambiguity resolution does not extend beyond initializer
2008-08-23 20:18 [Bug c++/37213] New: Declaration/expression ambiguity resolution does not extend beyond initializer akyrtzi at gmail dot com
@ 2008-08-24 22:30 ` pinskia at gcc dot gnu dot org
2008-08-24 22:43 ` akyrtzi at gmail dot com
2008-10-08 9:20 ` akyrtzi at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-24 22:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-08-24 22:28 -------
I think GCC is correct here.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37213
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/37213] Declaration/expression ambiguity resolution does not extend beyond initializer
2008-08-23 20:18 [Bug c++/37213] New: Declaration/expression ambiguity resolution does not extend beyond initializer akyrtzi at gmail dot com
2008-08-24 22:30 ` [Bug c++/37213] " pinskia at gcc dot gnu dot org
@ 2008-08-24 22:43 ` akyrtzi at gmail dot com
2008-10-08 9:20 ` akyrtzi at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: akyrtzi at gmail dot com @ 2008-08-24 22:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from akyrtzi at gmail dot com 2008-08-24 22:42 -------
I forgot to mention that both MSVC and Comeau compilers interpret
FuncType(a)(x,y)->z = 0;
as expression and compile the test program without errors.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37213
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/37213] Declaration/expression ambiguity resolution does not extend beyond initializer
2008-08-23 20:18 [Bug c++/37213] New: Declaration/expression ambiguity resolution does not extend beyond initializer akyrtzi at gmail dot com
2008-08-24 22:30 ` [Bug c++/37213] " pinskia at gcc dot gnu dot org
2008-08-24 22:43 ` akyrtzi at gmail dot com
@ 2008-10-08 9:20 ` akyrtzi at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: akyrtzi at gmail dot com @ 2008-10-08 9:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from akyrtzi at gmail dot com 2008-10-08 09:19 -------
And some bit of C++ standard wisdom:
C++ 6.8p1: "To disambiguate, the whole statement might have to be examined to
determine if it is an expression-statement or a declaration"
And there's this example given:
T(a)->m = 7; // expression-statement
I think the same applies to the example I gave:
T(a)(x,y)->m = 7; // should be an expression
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37213
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-08 9:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-23 20:18 [Bug c++/37213] New: Declaration/expression ambiguity resolution does not extend beyond initializer akyrtzi at gmail dot com
2008-08-24 22:30 ` [Bug c++/37213] " pinskia at gcc dot gnu dot org
2008-08-24 22:43 ` akyrtzi at gmail dot com
2008-10-08 9:20 ` akyrtzi at gmail dot com
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).