[libcxx-commits] [libcxx] [libc++] constexpr deque (PR #129368)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 11 04:09:37 PDT 2026


================
@@ -800,7 +802,19 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::emp
       difference_type __d = __back_spare();
       __d                 = (__d + 1) / 2;
       auto __new_end      = __end + __d;
-      __set_valid_range(std::move_backward(begin(), __end, __new_end), __new_end);
+      if (static_cast<size_type>(__d) >= size()) {
----------------
frederick-vs-ja wrote:

Previously, the unconditional `std::move_backward` call assigned values to some out-of-lifetime elements of `__split_buffer`, which was UB and could be correctly diagnosed by Clang. Ditto below.

I think we need to separate the assignments and constructions, for living and non-living elements respectively.

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


More information about the libcxx-commits mailing list