[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
Mon Oct 16 15:02:39 PDT 2023


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


philnik777 wrote:

> I don't see why it wouldn't be valid though -- we'd need to tie this back to something in the standard.

If that were valid we also wouldn't be allowed to EBO the deleter of `unique_ptr`s, since a user could do
```c++
ptr.get_deleter().~MyDeleter();
std::construct_at(&ptr.get_deleter()); // Could overwite the first byte of the pointer,
                                       // since the constructor is allowed to overwrite the padding
```
I realize that this isn't a standards reference. I'm pretty sure the standard is underspecified in this regard.

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


More information about the libcxx-commits mailing list