[PATCH] Add getSwappedBytes implementations for float / double

Mehdi Amini mehdi.amini at apple.com
Mon Jan 12 11:47:07 PST 2015

> On Jan 12, 2015, at 11:36 AM, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:
> On 01/12/2015 10:00 AM, Mehdi AMINI wrote:
>> It does not seems true in C, I'm unsure for C++.
> C99 7 says "When a value is stored in a member of an object of union type, the bytes of the object representation do not correspond to that member but do correspond to other members take unspecified values"
> I guess unspecified values could mean undefined behavior?

No it was made more clear by a footnote, see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_283.htm

78a If the member used to access 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.


More information about the llvm-commits mailing list