]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Check __cpp_exceptions in basic_string::reserve()
authorJonathan Wakely <jwakely@redhat.com>
Mon, 10 Aug 2020 11:02:18 +0000 (12:02 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 10 Aug 2020 11:02:18 +0000 (12:02 +0100)
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.

libstdc++-v3/include/bits/basic_string.tcc

index a64b63a37fbb6d41ec2fa57f654292cc19d8323d..95d2fdbd6d6a25eda2f7759362897927a97c8387 100644 (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>
This page took 0.277556 seconds and 5 git commands to generate.