aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/stl_bvector.h
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/bits/stl_bvector.h')
-rw-r--r--libstdc++-v3/include/bits/stl_bvector.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 59e7b7f967c..2c97d470582 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -604,7 +604,9 @@ template <typename _Alloc>
}
void reserve(size_type __n) {
- if (capacity() < __n) {
+ if (__n > this->max_size())
+ __throw_length_error("vector::reserve");
+ if (this->capacity() < __n) {
_Bit_type * __q = _M_bit_alloc(__n);
_M_finish = copy(begin(), end(), iterator(__q, 0));
_M_deallocate();