[libcxx-commits] [libcxx] [libc++] Fix UB in <expected> related to "has value" flag (#68552) (PR #68733)

Jan Kokemüller via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 27 13:08:12 PDT 2023


================
@@ -43,6 +44,17 @@ constexpr bool test() {
     assert(!e.has_value());
   }
 
+  // See comments of the corresponding test in
+  // "expected.expected/observers/has_value.pass.cpp".
+  {
+    const std::expected<void, TailClobberer<1>> e(std::unexpect);
+    // clang-cl does not support [[no_unique_address]] yet.
+#if !(defined(TEST_COMPILER_CLANG) && defined(_MSC_VER))
+    static_assert(sizeof(TailClobberer<1>) == sizeof(e));
+#endif
----------------
jiixyj wrote:

Done!

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


More information about the libcxx-commits mailing list