This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/38798] New: [c++0x] Trouble with struct/class/enum keyword in late return types
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jan 2009 22:31:04 -0000
- Subject: [Bug c++/38798] New: [c++0x] Trouble with struct/class/enum keyword in late return types
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following (IMHO valid) code snippet is rejected on trunk:
==============================
struct A {};
auto foo() -> struct A {}
==============================
bug.cc:2: error: redefinition of 'struct A'
bug.cc:1: error: previous definition of 'struct A'
bug.cc:2: error: expected initializer at end of input
Apparently {} is not treated as the function body, but as definition
of struct A. According to n2541, late function return types are type-ids.
Therefore {} shouldn't be parsed as type definition IMHO.
Btw, the following invalid code snippet is accepted:
==============================
auto foo() -> struct A {} {}
==============================
Again the first pair of {}'s is parsed as type definition.
In addition, the compiler doesn't complain about defining types
in a return type which has always been forbidden.
The same happens for enums:
==============================
enum E { e };
auto foo() -> enum E {}
==============================
==============================
auto foo() -> enum E {} {}
==============================
--
Summary: [c++0x] Trouble with struct/class/enum keyword in late
return types
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: rejects-valid, accepts-invalid, monitored
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38798