https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94337

--- Comment #3 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
Hmm... The code might actually be invalid, but I'm not sure. In all the
accesses, the effective type is the union type. But the C standard does not say
what happens when one takes the member of a union type.

* If the effective type remains the same (a union), then using any pointer cast
to another type would be invalid, but this could be unintuitive and break a lot
of code (and GCC should have emitted a warning for both printf lines).

* I suspect that the effective type is locally[*] changed to the type implied
by the type of the union member (this would be consistent with the GCC
warning). However, it seems that there is nothing about that in the C standard,
probably because the above example is really a corner case.

[*] not sure how this is supposed to mean precisely.
  • [Bug c/94337] Incorrect "d... vincent-gcc at vinc17 dot net via Gcc-bugs

Reply via email to