[libcxx-commits] [PATCH] D101206: [libc++] Remove UB in std::list
Amy Huang via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 23 16:22:50 PDT 2021
akhuang created this revision.
akhuang requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
The constructor of `__list_node` is never called, because it has a
member (`__value_`) that can't be constructed when we construct `__list_node`.
Putting `__value_` in a union solves the issue for C++11 and above, but C++03
doesn't allow putting classes with a non-trivial copy constructor in a union.
This patch stores `__value_` as aligned storage bytes when using c++03 and puts
reinterpret_casts everywhere it's used.
Continuation of https://reviews.llvm.org/D99624.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101206
Files:
libcxx/include/list
libcxx/include/optional
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101206.340195.patch
Type: text/x-patch
Size: 12898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210423/e6f17595/attachment-0001.bin>
More information about the libcxx-commits
mailing list