This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/9687: The & operator does not accept parentheses on operand


>Number:         9687
>Category:       c++
>Synopsis:       The & operator does not accept parentheses on operand
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 13 09:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Marc Durantez
>Release:        g++ (GCC) 3.2.2
>Organization:
>Environment:
Turbolinux 7.0
>Description:
The & operator followed by an operand enclosed in 
parentheses causes a parse error.

The following code gives a parse error on the line with
the &.

#include<iostream>

class MyClass
{
  int i;
};

int main()
{
  std::cout << (&(MyClass())) << "\n";
  return 0;
}

The error message is
printLocal.cpp: In function `int main()':
printLocal.cpp:10: parse error before `)' token

As far as I understand ISO14882 the code above should 
be legal. The code compiled without error on a 
different compiler.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]