[PATCH] D51869: NFC: bit.h don't warn on strict aliasing for GCC <= 7.1

JF Bastien via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 10 12:58:06 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL341853: NFC: bit.h don't warn on strict aliasing for GCC <= 7.1 (authored by jfb, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D51869

Files:
  llvm/trunk/include/llvm/ADT/bit.h


Index: llvm/trunk/include/llvm/ADT/bit.h
===================================================================
--- llvm/trunk/include/llvm/ADT/bit.h
+++ llvm/trunk/include/llvm/ADT/bit.h
@@ -26,7 +26,15 @@
 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51869.164733.patch
Type: text/x-patch
Size: 658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180910/4c397e7a/attachment.bin>


More information about the llvm-commits mailing list