diff options
| -rw-r--r-- | llvm/include/llvm/ADT/bit.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h index 8ea4746bf6e..00253c66178 100644 --- a/llvm/include/llvm/ADT/bit.h +++ b/llvm/include/llvm/ADT/bit.h @@ -26,7 +26,15 @@ template <typename To, typename From, inline To bit_cast(const From &from) noexcept { alignas(To) unsigned char storage[sizeof(To)]; std::memcpy(&storage, &from, sizeof(To)); +#if defined(__GNUC__) + // Before GCC 7.2, GCC thought that this violated strict aliasing. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif return reinterpret_cast<To &>(storage); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } } // namespace llvm |

