https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100004
Daniel Colascione <dancol at dancol dot org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dancol at dancol dot org --- Comment #2 from Daniel Colascione <dancol at dancol dot org> --- Let's talk about this. GCC might, surprisingly, actually be correct here: pointers are allowed to be cast from one object type to another object type and then back while retaining their validity; in principle, w1 and w2 might be "fake" wrapper instances created by casts from a struct Foo --- it's legal to form these fake pointers as long as no access occurs through them. If assign_via_pointer had reinterpret_cast<Foo*>()-ed w1 and w2 to Foo* (yielding f1 and f2 respectively) and then accessed f1->x and f2->x, I think we'd agree that f1->x and f2->x could alias. The difference between the code in this bug and the reinterpret_cast<> scenario is that here we're deriving f1 and f2 *not* via reinterpet_cast, but via regular member access --- &w1->foo and &w2->foo. Should the use of a member access instead of a cast propagate aliasing information? On one hand, it seems logical to do so; on the other hand, the standard *does* say that access through legally-derived same-type pointers can alias, and we *really do* have two legally-derived same-type pointers here. So what's the correct interpretation of the standard?