[Bug c++/50169] New: "new struct X {{}};" incorrectly treated as an invalid struct-definition
schaub.johannes at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Tue Aug 23 20:48:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50169
Bug #: 50169
Summary: "new struct X {{}};" incorrectly treated as an invalid
struct-definition
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: schaub.johannes@googlemail.com
The following looks like valid code:
struct A { int a; };
int main() {
new struct A {{ }};
}
The type-specifier-seq "struct A" is followed by a braced-init-list "{{}}". But
GCC says:
main1.cpp: In function 'int main()':
main1.cpp:3:16: error: types may not be defined in a new-type-id
main1.cpp:3:17: error: expected unqualified-id before '{' token
As far as I can see, I would only define a new type if I would say:
new struct A { };
But the two-braces disambiguates it.
More information about the Gcc-bugs
mailing list