Sample code snippet
const const const int x = 10;
int main()
{}
gets compiled in C but not in C++. Why does it get compiled in C? I thou
The C++0x grammar appears to allow it:
cv-qualifier-seq:
- cv-qualifier cv-qualifier-seq opt
cv-qualifier:
const volatile
Also, [decl.type.cv]
appears to allow it:
There are two cv-qualifiers,
const
andvolatile
. If a cv-qualifier appears in a decl-specifier-seq, the init-declarator-list of the declaration shall not be empty. [ Note: 3.9.3 and 8.3.5 describe how cv-qualifiers affect object and function types. — end note ] Redundant cv-qualifications are ignored. [ Note: For example, these could be introduced by typedefs. — end note ]