This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/9112: [gcc-3.4] new C++ parser rejects code older parsers accepted
- From: andrew at andypo dot net
- To: gcc-gnats at gcc dot gnu dot org
- Date: 31 Dec 2002 12:08:58 -0000
- Subject: c++/9112: [gcc-3.4] new C++ parser rejects code older parsers accepted
- Reply-to: andrew at andypo dot net
>Number: 9112
>Category: c++
>Synopsis: [gcc-3.4] new C++ parser rejects code older parsers accepted
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue Dec 31 04:16:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Andrew Pollard
>Release: gcc-3.4-20021230 (experimental)
>Organization:
>Environment:
gcc-3.4-20021230 (experimental)
>Description:
As confirmed on the gcc mailing list, the following code should compile
[ http://gcc.gnu.org/ml/gcc/2002-12/msg01615.html ]
a.cxx:
-------------------------
struct A {
int a, b;
A(int i, int j) : a(i), b(j) {}
void foo() {};
};
int
main()
{
int a = 2;
A(a, a).foo();
return (0);
}
--------------------------
% g++34 a.cxx
a.cxx: In function `int main()':
a.cxx:11: error: conflicting types for `A a'
a.cxx:10: error: previous declaration as `int a'
a.cxx:11: error: expected init-declarator
a.cxx:11: error: expected `,' or `;'
It appears to think that I want to declare a new variable 'a' with type 'A', whereas I want to construct a temporary A(2,2) and invoke foo() on it.
Previous versions of g++ work (3.0-cvs, 3.2-cvs, 3.3-cvs) and so do icc-70 and VC++6.0
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: