This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]