[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 10:01:02 PDT 2023
https://github.com/huixie90 commented:
Thanks for spotting the issue and send the PR. I am still a bit nervous about object overlapping. Since `expected` can expose its data through several members like `operator*`, `operator->`, `value()`, `error()`, etc.... Could users trigger this UB by other means that we can not stop from. like
```
std::expected<T, U> e = ...;
e->someMemberThatCouldWriteToObjectThatChangesHasValue()
```
or even,
```
std::expected<T, U> e = ...;
std::construct_at( std::address_of(*e), args...);
```
What do you think?
https://github.com/llvm/llvm-project/pull/68733
More information about the libcxx-commits
mailing list