Skip to content

Commit 7427c99

Browse files
committed
[libc++][C++03] Cherry-pick llvm#116449 and llvm#113086
1 parent 6712e20 commit 7427c99

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

libcxx/include/__cxx03/vector

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,12 @@ public:
432432
template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
433433
_LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x, const allocator_type& __a)
434434
: __end_cap_(nullptr, __a) {
435+
auto __guard = std::__make_exception_guard(__destroy_vector(*this));
435436
if (__n > 0) {
436437
__vallocate(__n);
437438
__construct_at_end(__n, __x);
438439
}
440+
__guard.__complete();
439441
}
440442

441443
template <class _InputIterator,
@@ -1054,9 +1056,7 @@ inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x, const
10541056
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
10551057
} else {
10561058
typedef move_iterator<iterator> _Ip;
1057-
auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1058-
assign(_Ip(__x.begin()), _Ip(__x.end()));
1059-
__guard.__complete();
1059+
__init_with_size(_Ip(__x.begin()), _Ip(__x.end()), __x.size());
10601060
}
10611061
}
10621062

libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// (bug report: https://llvm.org/PR58392)
1212
// Check that vector constructors don't leak memory when an operation inside the constructor throws an exception
1313

14-
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
15-
1614
#include <cstddef>
1715
#include <memory>
1816
#include <type_traits>

0 commit comments

Comments
 (0)