[PATCH] Add getSwappedBytes implementations for float / double
mehdi.amini at apple.com
Mon Jan 12 12:07:23 PST 2015
> On Jan 12, 2015, at 11:56 AM, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:
> On 01/12/2015 11:47 AM, Mehdi Amini wrote:
>>> 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 126.96.36.199 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.
> So should I just switch to not using the memcpy? Also, do you think it would be more appropriate to move this to EndianWriter?
And I don’t know for the appropriate location for this code, I’m too new to LLVM for that.
More information about the llvm-commits