[Bug libstdc++/77686] [6/7 Regression] wrong code on arm-linux-gnueabi and arm-linux-gnueabihf

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Sep 27 10:11:00 GMT 2016


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

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
Just to explain a little bit.  Consider

void foo (void)
{
  union { float f; char c[4]; } u, v;
  *(int *)&u = 0;
  v = u;
  return *(int *)&v;
}

then C11 6.5/6,7 make it clear that it is not valid to use 'u' (of union type)
to access the object which now has effective type 'int' (in fact that store
alone, given strict reading of C11 6.5/6 is invalid as u has a declared type).
The union does not have 'int' amongst its members.  Putting 'char' or an
array of 'char' into the union does not make the access fall under 6.5/7
as 'a character type' only follows 'an aggregate or union type that includes
one
of the _AFOREMENTIONED_ types...' (emphasis mine).

GCC allows even objects with a declared type to take any effective type by
means of storing to it with that type (to support existing practice and
multiple languages).


More information about the Gcc-bugs mailing list