No arguments over good style, I'm just interested here in what is legal in standard c++. This is a small example of something that came up in a much bigger bit of code.
Clang and Visual Studio compile this without error and it appears to work perfectly well. I don't even get a warning from either.
GCC gives the following error and refuses to even compile the code...
test.cpp:1:8: error: changes meaning of 'test' from 'struct test' [-fpermissive]
Is this legal code, or not? I understand what gcc is saying, but is this code actually in error?
struct test
{
int data;
};
struct app
{
test test;
};
int main()
{
app myapp;
myapp.test.data = 123;
}