Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • I would argue about disabling strict aliasing to access a common initiail sequence of non-compatible struct types. Putting both of the types as union members and accessing their common initial sequence from anywhere where the union declaration is visible is a conforming way, isn't? Commented Apr 6, 2019 at 6:48
  • 1
    @SomeName: Under the gcc/clang interpretation, operations that take the addresses of union members and use the resulting pointers are unsupported *even in cases where nothing else accesses the storage between the time the address is taken and the pointer is used. Even something like *(someUnion.memberOfArrayType+index) can fail. The Standard doesn't forbid such behavior because the authors expected that compiler writers would limit application of the rule to cases involving aliasing of seemingly-unrelated objects. More generally, the Standard deliberately allows... Commented Apr 7, 2019 at 0:48
  • 1
    ...implementations specialized for narrow purposes to behave in ways that would benefit those purposes, even when that would make them unsuitable for many others. As a consequence of that, it makes no attempt to pass judgment as to what behaviors might render an implementation unsuitable for almost any purpose. Commented Apr 7, 2019 at 0:50