[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:22:33 PDT 2023
================
@@ -452,9 +412,10 @@ class expected {
std::destroy_at(std::addressof(__union_.__val_));
} else {
std::destroy_at(std::addressof(__union_.__unex_));
- __has_val_ = true;
}
- return *std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...);
+ std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...);
+ __has_val_ = true;
+ return *std::addressof(__union_.__val_);
}
----------------
jiixyj wrote:
Agreed, `TailClobberer` tests for `swap()` are still missing. I can do this in this PR, shouldn't be too difficult/complex I'd think.
https://github.com/llvm/llvm-project/pull/68733
More information about the libcxx-commits
mailing list