On 2015-03-08 13:15:53 +0800, Thomas Preud'homme wrote:
> If there is a lot of such union some space might be saved but I'm not 
> convinced it's significant. Setting a value in one field and accessing it in 
> another is forbidden by the C standard I think (aliasing?)

It isn't forbidden, though the rules in 6.5/7 are very unclear. But
there's a note of 6.5.2.3/3 that makes them clear for the union:

  If the member used to read the contents of a union object is not
  the same as the member last used to store a value in the object,
  the appropriate part of the object representation of the value
  is reinterpreted as an object representation in the new type as
  described in 6.2.6 (a process sometimes called "type punning").
  This might be a trap representation.

The problem here is more with integer representation in memory
(endianness, presence of padding bits...).

-- 
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to