Is it legal to have fields with the same name across different anonymous unions inside one union?
union Foo
{
union
{
int bar;
};
union
{
int bar;
};
};
This code fails to compile by GCC but works fine in MSVC.
cl
. Disable language extensions (/Za
) and happily get:error C2658: 'Foo::bar': redefinition in anonymous struct/union
– Stomatic