Fix an off-by-one error in basic_string::__grow_by, where it would incorrectly throw length_error (instead of bad_alloc) when attempting to resize the string to 'max_size()'. Add tests for resizing to max_size +/-1
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@194151 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/string b/include/string
index 234eb6b..e8bd69f 100644
--- a/include/string
+++ b/include/string
@@ -2181,7 +2181,7 @@
size_type __n_copy, size_type __n_del, size_type __n_add)
{
size_type __ms = max_size();
- if (__delta_cap > __ms - __old_cap - 1)
+ if (__delta_cap > __ms - __old_cap)
this->__throw_length_error();
pointer __old_p = __get_pointer();
size_type __cap = __old_cap < __ms / 2 - __alignment ?