On 18 December 2015 at 16:47, Jonathan Wakely <jwak...@redhat.com> wrote:
> It only occurs to me now (rather than when I first suggested this
> change) that it changes behaviour for users who have replaced operator
> new, but not replaced the nothrow_t version.
>
> But I can't believe that anyone would replace operator new *just* to
> alter the behaviour of std::ios pword/iword allocation, and the
> precise form of allocation used is unspecified, so I don't think
> anyone can reasonably be hurt by this change (and it's good for
> people who want to build the library with -fno-exceptions).
>
> OK for trunk, thanks.

Here's a fix for the regression that the patch introduced. Tested with
-m32 on Linux-X64.

2015-12-18  Ville Voutilainen  <ville.voutilai...@gmail.com>

    Fix a regression introduced by the fix of libstdc++/68276.
    * src/c++11/ios.cc (_M_grow_words): Catch bad_alloc again so that
    bad_array_new_length is handled properly.
diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc
index f701e61..17dad55 100644
--- a/libstdc++-v3/src/c++11/ios.cc
+++ b/libstdc++-v3/src/c++11/ios.cc
@@ -121,7 +121,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        if (__ix < numeric_limits<int>::max())
          {
            __newsize = __ix + 1;
-           __words = new (std::nothrow) _Words[__newsize];
+           /* We still need to catch bad_alloc even though we use
+              a nothrow new, because the new-expression can throw
+              a bad_array_new_length.  */
+           __try
+             { __words = new (std::nothrow) _Words[__newsize]; }
+           __catch(const std::bad_alloc&)
+             { __words = nullptr; }
            if (!__words)
              {
                _M_streambuf_state |= badbit;

Reply via email to