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

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 27 08:55:25 PDT 2023


Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokem=C3=BCller?= <jan.kokemueller at gmail.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/68733/libcxx at github.com>


================
@@ -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
----------------
ldionne wrote:

Same here, I recommend `LIBCPP_STATIC_ASSERT`.

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


More information about the libcxx-commits mailing list