This code
int clash;
struct Foo {
decltype(clash) clash;
};
compiles silently on clang, but fails to compile on gcc giving the errors
error: declaration of 'int Foo::clash' [-fpermissive]
error: changes meaning of 'clash' from 'int clash' [-fpermissive]
It seems that 2 ingredients are required for the error to arise:
The shadowing must be done by a class member (no problem if it's a function's local scope).
decltype([shadowed name]) must be used in the shadowing scope before the declaration of [shadowing name].
My question is twofold:
- Is gcc justified in rejecting this code?
- Where does it say so in the standard?