Example:
int main()
{
int a = 0;
struct X
{
decltype(a) a;
};
return 0;
}
The decltype(a) refers to the local a in main, while the member it declares shares the same name.
Clang compiles w/o any problem, so does MSVC14.
G++ complains on it, adding -fpermissive makes it pass though
prog.cc:6:21: error: declaration of 'int main()::X::a' [-fpermissive]
decltype(a) a;
^
prog.cc:3:9: error: changes meaning of 'a' from 'int a' [-fpermissive]
int a = 0;
Which behavior is standard-conformant?
Aucun commentaire:
Enregistrer un commentaire