Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions libcxx/include/__cxx03/vector
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ private:
return __n * __bits_per_word;
}
_LIBCPP_HIDE_FROM_ABI static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT {
return (__n - 1) / __bits_per_word + 1;
return __n > 0 ? (__n - 1) / __bits_per_word + 1 : size_type(0);
}

public:
Expand Down Expand Up @@ -2142,11 +2142,13 @@ void vector<bool, _Allocator>::reserve(size_type __n) {

template <class _Allocator>
void vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT {
if (__external_cap_to_internal(size()) > __cap()) {
if (__external_cap_to_internal(size()) < __cap()) {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
vector(*this, allocator_type(__alloc())).swap(*this);
vector __v(*this, allocator_type(__alloc()));
if (__v.__cap() < __cap())
__v.swap(*this);
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

// void shrink_to_fit();

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <cassert>
#include <climits>
#include <vector>
Expand Down
Loading