tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] CValue


From: Vincent Lefevre
Subject: Re: [Tinycc-devel] CValue
Date: Sun, 8 Mar 2015 09:57:31 +0100
User-agent: Mutt/1.5.23-6425-vl-r76280 (2015-03-04)

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 <address@hidden> - 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]