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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ messages in thread

* [Bug c++/37213] Declaration/expression ambiguity resolution does not extend beyond initializer
       [not found] <bug-37213-4@http.gcc.gnu.org/bugzilla/>
  2010-12-27 11:24 ` schaub.johannes at googlemail dot com
@ 2010-12-27 14:37 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2010-12-27 14:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37213

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2010.12.27 14:36:50
     Ever Confirmed|0                           |1

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-27 14:36:50 UTC ---
(In reply to comment #0)
> typedef S* (*FuncType)(int,int);
> int x,y;
> S* a() {
>   FuncType(a)(x,y)->z = 0; // treated as declaration

calling 'a' through a function pointer of a different type is undefined
behaviour, but fixing that doesn't change the error, which I agree is wrong.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/37213] Declaration/expression ambiguity resolution does not extend beyond initializer
       [not found] <bug-37213-4@http.gcc.gnu.org/bugzilla/>
@ 2010-12-27 11:24 ` schaub.johannes at googlemail dot com
  2010-12-27 14:37 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 6+ messages in thread
From: schaub.johannes at googlemail dot com @ 2010-12-27 11:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37213

Johannes Schaub <schaub.johannes at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schaub.johannes at
                   |                            |googlemail dot com

--- Comment #4 from Johannes Schaub <schaub.johannes at googlemail dot com> 2010-12-27 11:24:36 UTC ---
Same problem happens with

int m;
int(m), m++;

I think GCC is wrong rejecting this.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-12-27 14:37 UTC | newest]

Thread overview: 6+ 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
     [not found] <bug-37213-4@http.gcc.gnu.org/bugzilla/>
2010-12-27 11:24 ` schaub.johannes at googlemail dot com
2010-12-27 14:37 ` redi 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).