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

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Oct 14 15:36:55 PDT 2023


================
@@ -1552,6 +1528,18 @@ class expected<_Tp, _Err> {
     _LIBCPP_NO_UNIQUE_ADDRESS _ErrorType __unex_;
   };
 
+  template <class _Up, class _OtherErr>
+  _LIBCPP_HIDE_FROM_ABI constexpr __union_t<_Err> __union_from_expected(const expected<_Up, _OtherErr>& __other) {
+    return __other.__has_val_ ? __union_t<_Err>()
----------------
huixie90 wrote:

not sure. I did not add templates in my version and it was added here:
https://github.com/llvm/llvm-project/commit/acce2a315945e386a7be6f014ebe90c2a28f38d9#diff-99bc4a85cb97f33ff277458a531ca47376ceba6ea7d84329cabf02857941ed3e

I missed the review of that patch

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


More information about the libcxx-commits mailing list