[Bug middle-end/87363] Duplicate and bogus -Wstringop-overflow warning
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 19 17:38:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87363
--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Wed, 19 Sep 2018, msebor at gcc dot gnu.org wrote:
> Other than that, since
>
> When a value is stored in a member of an object of union type, the bytes of
> the object representation that do not correspond to that member but do
> correspond to other members take unspecified values.
>
> the value of u.z is unspecified after the initialization of the union u in the
> test case.
No, that's only about those bytes that are outside the member that was
stored (so if you have a union between int and double, and store in the
int, the parts of the double after the initial sizeof (int) bytes become
undefined, for example). Type-punning between union members (when you
explicitly access using the union type), up to the lesser of the sizes of
the two members in question, has been defined since C99 TC3 (in a
footnote, so not normative, but the intent is clear).
More information about the Gcc-bugs
mailing list