[libcxx-commits] [libcxx] [libc++][ranges][abi-break] Fix `movable_box` overwriting memory of data that lives in the tail padding (PR #71314)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 15 09:54:15 PST 2023


================
@@ -144,23 +151,47 @@ concept __doesnt_need_empty_state_for_move = movable<_Tp> || is_nothrow_move_con
 
 template <class _Tp>
 concept __doesnt_need_empty_state = __doesnt_need_empty_state_for_copy<_Tp> && __doesnt_need_empty_state_for_move<_Tp>;
+
+template <class _Tp>
+concept __can_use_no_unique_address = copyable<_Tp>;
 #  endif
 
+template <class _Tp>
+struct __movable_box_base {
+  _Tp __val_;
+
+  template <class... _Args>
+    requires is_constructible_v<_Tp, _Args&&...>
----------------
ldionne wrote:

I would suggest dropping these `requires` inside `__movable_box_base`, since they're already checked in `__movable_box`. It makes the code just a bit simpler and makes it clearer that requirement-checking in this helper class is not necessary.

However, you can add `in_place_t` to disambiguate with any copy constructor, and it's also consistent with the constructor for `__movable_box` itself.

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


More information about the libcxx-commits mailing list