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

David Blaikie dblaikie at gmail.com
Mon Feb 11 13:09:46 PST 2013


On Sat, Feb 9, 2013 at 10:07 PM, Chris Lattner <sabre at nondot.org> wrote:
> Author: lattner
> Date: Sun Feb 10 00:07:16 2013
> New Revision: 174826
>
> URL: http://llvm.org/viewvc/llvm-project?rev=174826&view=rev
> Log:
> hopefully "really" fix a type punning warning by defining the buffer as
> type char, which can't have TBAA tags.
>
> Modified:
>     llvm/trunk/include/llvm/Bitcode/BitstreamReader.h
>
> Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=174826&r1=174825&r2=174826&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original)
> +++ 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?

- David

>
>      NextChar += sizeof(word_t);
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list