[libcxx-commits] [libcxx] 0ebcc97 - [libc++][C++03] Cherry-pick #116449 and #113086 (#163362)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 14 04:01:28 PDT 2025


Author: Nikolas Klauser
Date: 2025-10-14T13:01:25+02:00
New Revision: 0ebcc97e1148b5a3863ebf8c669a71450fe3a531

URL: https://github.com/llvm/llvm-project/commit/0ebcc97e1148b5a3863ebf8c669a71450fe3a531
DIFF: https://github.com/llvm/llvm-project/commit/0ebcc97e1148b5a3863ebf8c669a71450fe3a531.diff

LOG: [libc++][C++03] Cherry-pick #116449 and #113086 (#163362)

Added: 
    

Modified: 
    libcxx/include/__cxx03/vector
    libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__cxx03/vector b/libcxx/include/__cxx03/vector
index 4b62e0bf33c46..dbaa33c442948 100644
--- a/libcxx/include/__cxx03/vector
+++ b/libcxx/include/__cxx03/vector
@@ -432,10 +432,12 @@ public:
   template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
   _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x, const allocator_type& __a)
       : __end_cap_(nullptr, __a) {
+    auto __guard = std::__make_exception_guard(__destroy_vector(*this));
     if (__n > 0) {
       __vallocate(__n);
       __construct_at_end(__n, __x);
     }
+    __guard.__complete();
   }
 
   template <class _InputIterator,
@@ -1054,9 +1056,7 @@ inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x, const
     __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
   } else {
     typedef move_iterator<iterator> _Ip;
-    auto __guard = std::__make_exception_guard(__destroy_vector(*this));
-    assign(_Ip(__x.begin()), _Ip(__x.end()));
-    __guard.__complete();
+    __init_with_size(_Ip(__x.begin()), _Ip(__x.end()), __x.size());
   }
 }
 

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp
index 00de05347bfd9..679eec2413793 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp
@@ -11,8 +11,6 @@
 // (bug report: https://llvm.org/PR58392)
 // Check that vector constructors don't leak memory when an operation inside the constructor throws an exception
 
-// XFAIL: FROZEN-CXX03-HEADERS-FIXME
-
 #include <cstddef>
 #include <memory>
 #include <type_traits>


        


More information about the libcxx-commits mailing list