libstdc++: Check __cpp_exceptions in basic_string::reserve()

If exceptions are disabled then reallocating could abort, so ignore
shrink-to-fit requests.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.tcc [_GLIBCXX_USE_CXX11_ABI=0]
	(basic_string::reserve()): Do nothing if exceptions are not
	enabled.
This commit is contained in:
Jonathan Wakely 2020-08-10 12:02:18 +01:00
parent 7b7bbbcf51
commit 8bd92d8097

View File

@ -1179,6 +1179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
basic_string<_CharT, _Traits, _Alloc>::
reserve()
{
#if __cpp_exceptions
if (length() < capacity() || _M_rep()->_M_is_shared())
try
{
@ -1191,6 +1192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ throw; }
catch (...)
{ /* swallow the exception */ }
#endif
}
template<typename _CharT, typename _Traits, typename _Alloc>