From 6b24f7429a4fb2c8af088dea14b1f9b902c98502 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 10 Feb 2013 06:36:29 +0000 Subject: [PATCH] ok, ok, stop fighting type punning warnings by just using a union. llvm-svn: 174827 --- llvm/include/llvm/Bitcode/BitstreamReader.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/Bitcode/BitstreamReader.h b/llvm/include/llvm/Bitcode/BitstreamReader.h index 48a6989..edec6e1 100644 --- a/llvm/include/llvm/Bitcode/BitstreamReader.h +++ b/llvm/include/llvm/Bitcode/BitstreamReader.h @@ -364,13 +364,16 @@ public: uint32_t R = uint32_t(CurWord); // Read the next word from the stream. - char buf[sizeof(word_t)] = {0}; - BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(buf), - (uint8_t*)buf, NULL); + union { + uint8_t ArrayMember[sizeof(word_t)]; + support::detail::packed_endian_specific_integral + EndianMember; + } buf = { { 0 } }; - typedef support::detail::packed_endian_specific_integral - Endian_T; - CurWord = *(Endian_T*)buf; + BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(buf), + buf.ArrayMember, NULL); + // Handle big-endian byte-swapping if necessary. + CurWord = buf.EndianMember; NextChar += sizeof(word_t); -- 2.7.4