[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
Sun Oct 15 10:57:22 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>


huixie90 wrote:

> > As an alternative, I wonder if the current ABI is salvageable by saving/restoring tail padding in all "dangerous" functions (i.e. swap, emplace, assign, etc.) with something like:
> > [...]
> 
> I tried something similar on a separate branch as a POC: [jiixyj at 86fe890#diff-99bc4a85cb97f33ff277458a531ca47376ceba6ea7d84329cabf02857941ed3eR976](https://github.com/jiixyj/llvm-project/commit/86fe89005ba6a3f0d8769b574274cc5192462216#diff-99bc4a85cb97f33ff277458a531ca47376ceba6ea7d84329cabf02857941ed3eR976)
> 
> All `std::construct_at`/`std::destroy_at` calls are funneled through helper functions that save/restore just the minimum amount of bytes that might be overwritten by the constructor/destructor, including the `__has_value_` flag.
> 
> Could that be a way out of this?

But I guess it won't work in constant expression and it does not work in multithreading cases as the memory is changed then changed it back later

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


More information about the libcxx-commits mailing list