[compiler-rt] [llvm] [cpp23] Remove usage of std::aligned_union<> in llvm (PR #135146)

A. Jiang via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 02:20:13 PDT 2025


================
@@ -367,8 +367,8 @@ template <typename T> class ORC_RT_NODISCARD Expected {
   }
 
   union {
-    std::aligned_union_t<1, storage_type> TStorage;
-    std::aligned_union_t<1, error_type> ErrorStorage;
+    alignas(storage_type) char TStorage[sizeof(storage_type)];
+    alignas(error_type) char ErrorStorage[sizeof(error_type)];
----------------
frederick-vs-ja wrote:

No change requested. FYI, pedantic reading of [[intro.object]/3](https://eel.is/c++draft/intro.object#3) suggests that `unsigned char` or `std::byte` should be used instead of `char` in these places.

https://github.com/llvm/llvm-project/pull/135146


More information about the llvm-commits mailing list