The aliasing is a time bomb. E.g.:
Code:
struct A {
int s;
int i;
};
struct B {
int s;
char buffer[4];
};
bool test(A& a, B& b) {
b.buffer[0] = 1;
a.i = 0;
return a.i == b.buffer[0];
}
GCC 5.4 leaves the "a.i == b.buffer[0]" check in place. GCC 6.3 concludes that "a" and "b" cannot alias and optimizes the check away and produces the wrong result.

Originally Posted by
hubbe
If I'm reading the standard right, this is still undefined behavior, the compiler just doesn't complain about it anymore.
Yes.
As far as I can tell, casting to a struct and then using is no longer supported in C++-11, so there goes 39 years of backwards compatibility....
It wasn't legal in the first place. This is not something new with C++-11.
Anyways, it looks like unions is the new hotness, which is silly, because it ends up doing the same thing.
Using a union for type punning is not legal in C++ (it is in C99 / C11).
GCC, CLang and ICC all support "__attribute((__may_alias__))", which gets you the correct behavior. E.g.:
Code:
struct A {
int s;
int i;
} __attribute((__may_alias__));