[Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jan 31 22:09:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-01-31 21:26:41 UTC ---
It seems to me that all these examples should be rejected (Thanks to Jens
Maurer for helping me here): At first it seems, that we can follow the grammar
chain starting from /declaration/ in 7 [dcl.dcl] via
simple-declaration => decl-specifier-seq_opt init-declarator-list_opt;
without the optional init-declarator-list reaching
decl-specifier => type-specifier => trailing-type-specifier =>
simple-type-specifier => decltype(expression).
But the show-stopper for this is 7 [dcl.dcl] p3:
"In a simple-declaration, the optional init-declarator-list can be omitted only
when declaring a class (Clause 9) or enumeration (7.2), that is, when the
decl-specifier-seq contains either a class-specifier, an elaborated-type-
specifier with a class-key (9.1), or an enum-specifier. [..]"
Neither of these three situations applies, so this is no valid
/simple-declaration/.
More information about the Gcc-bugs
mailing list