https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
--- Comment #12 from James Kuyper Jr. <jameskuyper at verizon dot net> --- (In reply to Wolfgang Bangerth from comment #2) > I can't believe the wording means what you imply. Assume that caller > and callee are in different translation units, then there is no > way for the compiler to see that the two arguments to the called function > may in fact be members of the same union. Complying with this requirement does not require positively determining whether they are members of the same union. It requires only that code be generated that would correctly handle the possibility that they are members of the same union. This basically means that anti-aliasing optimizations that would ordinarily be enabled by the fact that two struct types are different would have to be disabled anywhere within the scope of such a union declaration unless a) the implementation can be certain that they aren't different members of the same union object OR b) the implementation applies those optimizations only if the relevant pointers do not point at the same location. > So the only way to assume that they could alias each other is to > search the universe for a union type in which both of them are members. > That certainly can't be the intent of the standard or DR. It only makes > sense, if as RTH says the access is through such a union. Why would it be necessary to "search the universe"? The rule very explicitly only applies "anywhere that a declaration of the complete type of the union is visible." Whether such a declaration is currently visible is something the implementation must already keep track of, in order to determine whether the definition of an object of the union's type is permitted.