Fixes PR17148
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@193772 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4259337da2
commit
09f8550e1c
@ -3047,9 +3047,9 @@ basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
|
|||||||
{
|
{
|
||||||
size_type __m = __alloc_traits::max_size(__alloc());
|
size_type __m = __alloc_traits::max_size(__alloc());
|
||||||
#if _LIBCPP_BIG_ENDIAN
|
#if _LIBCPP_BIG_ENDIAN
|
||||||
return (__m <= ~__long_mask ? __m : __m/2) - 1;
|
return (__m <= ~__long_mask ? __m : __m/2) - __alignment;
|
||||||
#else
|
#else
|
||||||
return __m - 1;
|
return __m - __alignment;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,12 @@ void
|
|||||||
test(const S& s)
|
test(const S& s)
|
||||||
{
|
{
|
||||||
assert(s.max_size() >= s.size());
|
assert(s.max_size() >= s.size());
|
||||||
|
{
|
||||||
|
S s2;
|
||||||
|
try { s2.resize(s2.max_size() - 1, 'x'); }
|
||||||
|
catch ( const std::bad_alloc & ) { return ; }
|
||||||
|
assert ( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user