re PR libstdc++/68276 (ios_base::_M_grow_words should use new (std::nothrow))
authorVille Voutilainen <ville.voutilainen@gmail.com>
Fri, 18 Dec 2015 15:17:09 +0000 (17:17 +0200)
committerVille Voutilainen <ville@gcc.gnu.org>
Fri, 18 Dec 2015 15:17:09 +0000 (17:17 +0200)
2015-12-18  Ville Voutilainen  <ville.voutilainen@gmail.com>

PR libstdc++/68276

* src/c++11/ios.cc (_M_grow_words): Use nothrow new.
* testsuite/27_io/ios_base/storage/11584.cc: Adjust.

From-SVN: r231819

libstdc++-v3/ChangeLog
libstdc++-v3/src/c++11/ios.cc
libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc

index 6a8fa76fa040d107416063c061a97fa188eeaa14..a37878d7867083a13f91d704984bec7205401d4a 100644 (file)
@@ -1,3 +1,10 @@
+2015-12-18  Ville Voutilainen  <ville.voutilainen@gmail.com>
+
+       PR libstdc++/68276
+
+       * src/c++11/ios.cc (_M_grow_words): Use nothrow new.
+       * testsuite/27_io/ios_base/storage/11584.cc: Adjust.
+
 2015-12-18  Andris Pavenis  <andris.pavenis@iki.fi>
 
        * config/os/djgpp/error_constants.h: update according to DJGPP errno
index 4adc701929366eccea2319b8be805ba9cd759724..f701e61f0d0cb9a61a420f57826c6a86bc3ecfce 100644 (file)
@@ -121,9 +121,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        if (__ix < numeric_limits<int>::max())
          {
            __newsize = __ix + 1;
-           __try
-             { __words = new _Words[__newsize]; }
-           __catch(const std::bad_alloc&)
+           __words = new (std::nothrow) _Words[__newsize];
+           if (!__words)
              {
                _M_streambuf_state |= badbit;
                if (_M_streambuf_state & _M_exception)
index 0c80795dfde38fbc88396f2ad21acba78cddd54f..ae680c7d7bf612706054f59f5398498b3fcad004 100644 (file)
 
 int new_fails;
 
-void* operator new(std::size_t n) throw (std::bad_alloc)
+void* operator new(std::size_t n, const std::nothrow_t&) throw()
 {
   if (new_fails)
-    throw std::bad_alloc();  
+    return 0;
   return malloc(n);
 }
-void* operator new[] (std::size_t n) throw (std::bad_alloc)
-{ return operator new(n); }
+void* operator new[] (std::size_t n, const std::nothrow_t& ntt) throw()
+{ return operator new(n, ntt); }
 
 void operator delete (void *p) throw() { free(p); }
 void operator delete[] (void *p) throw() { operator delete(p); }