This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 31 Jan 2012 21:26:41 +0000
- Subject: [Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
- Auto-submitted: auto-generated
- References: <bug-51786-4@http.gcc.gnu.org/bugzilla/>
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/.