llvm.org GIT mirror llvm / ef953d7
NFC: bit.h don't warn on strict aliasing for GCC <= 7.1 Summary: Addressed https://bugs.llvm.org/show_bug.cgi?id=38885 Subscribers: dexonsmith, llvm-commits, rsmith, steven_wu, RKSimon, Abhilash, srhines Differential Revision: https://reviews.llvm.org/D51869 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341853 91177308-0d34-0410-b5e6-96231b3b80d8 JF Bastien 1 year, 10 months ago
1 changed file(s) with 8 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2525 inline To bit_cast(const From &from) noexcept {
2626 alignas(To) unsigned char storage[sizeof(To)];
2727 std::memcpy(&storage, &from, sizeof(To));
28 #if defined(__GNUC__)
29 // Before GCC 7.2, GCC thought that this violated strict aliasing.
30 #pragma GCC diagnostic push
31 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
32 #endif
2833 return reinterpret_cast(storage);
34 #if defined(__GNUC__)
35 #pragma GCC diagnostic pop
36 #endif
2937 }
3038
3139 } // namespace llvm