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

--- Comment #4 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Vincent Lefèvre from comment #3)
> * 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).

Well, not the pointer cast itself, but an access to the memory after a
conversion of the pointer type (even in the case where the pointer type matches
the type of the member, as in ((struct s2 *) u.m2)->b).

Note: the code example is derived from experimental GNU MPFR code (ubf2 branch)
as an attempt to avoid aliasing issues in the current code without breaking the
API or introducing drawbacks.
  • [Bug c/94337] Incorrect "d... vincent-gcc at vinc17 dot net via Gcc-bugs
    • [Bug c/94337] Incorrect &q... vincent-gcc at vinc17 dot net via Gcc-bugs

Reply via email to