[llvm] r174826 - hopefully "really" fix a type punning warning by defining the buffer as

Chris Lattner clattner at apple.com
Tue Feb 12 20:50:01 PST 2013


On Feb 11, 2013, at 1:09 PM, David Blaikie <dblaikie at gmail.com> wrote:

>> +++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Sun Feb 10 00:07:16 2013
>> @@ -364,12 +364,13 @@ public:
>>     uint32_t R = uint32_t(CurWord);
>> 
>>     // Read the next word from the stream.
>> -    uint8_t buf[sizeof(word_t)] = {0};
>> -    BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(buf), buf, NULL);
>> +    char buf[sizeof(word_t)] = {0};
>> +    BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(buf),
>> +                                           (uint8_t*)buf, NULL);
>> 
>>     typedef support::detail::packed_endian_specific_integral
>>        <word_t, support::little, support::unaligned> Endian_T;
>> -    CurWord = *(Endian_T*)(void*)buf;
>> +    CurWord = *(Endian_T*)buf;
> 
> Why not just use memcpy to do this in a well defined manner?

Will do.

-Chris



More information about the llvm-commits mailing list