From patchwork Wed Dec 16 22:12:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ville Voutilainen X-Patchwork-Id: 557787 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3CB431402C9 for ; Thu, 17 Dec 2015 09:12:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=LeO80b+D; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=SmkrpcIWB6QjeSOZ2LVIwZiV3Z2w10yZgKZ3NWSkSr2MZ2 MlXRZVnzq5ytNNuOisqZXkm9NWXTK376JlA1wKisCqXRQ82GrperivOCST0WS5cJ jlhpKJtCyYhA5HXpFWTnZzd+Jj3Avr8BcZKSzQi5ASI7iRHOScWuTufJia9LI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=mzraKXVLlU8nWRWR+AWzMvQomIk=; b=LeO80b+DwlkkVXDLBtlU avMaLeZxV9e1Qd0o+jk9DwmSO+rEIHswIOU6tLIorUs9u/vclzra6vngaYW/fPKd +Ggpr7oIq2z23q3i2B5hVL/mKGNVwqF8cBaNZKn0Jr8taVkzm9BO6MUFXqiTtdpC H5/j4/4Nm3oE/qFIIp+513I= Received: (qmail 56745 invoked by alias); 16 Dec 2015 22:12:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 56723 invoked by uid 89); 16 Dec 2015 22:12:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_40, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=20151217, 2015-12-17, 11584.cc, UD:11584.cc X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-vk0-f41.google.com Received: from mail-vk0-f41.google.com (HELO mail-vk0-f41.google.com) (209.85.213.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 16 Dec 2015 22:12:37 +0000 Received: by mail-vk0-f41.google.com with SMTP id a189so35455225vkh.2; Wed, 16 Dec 2015 14:12:37 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.31.52.201 with SMTP id b192mr37874755vka.101.1450303955111; Wed, 16 Dec 2015 14:12:35 -0800 (PST) Received: by 10.103.112.130 with HTTP; Wed, 16 Dec 2015 14:12:34 -0800 (PST) Date: Thu, 17 Dec 2015 00:12:34 +0200 Message-ID: Subject: [v3 PATCH] PR libstdc++/68276 From: Ville Voutilainen To: "gcc-patches@gcc.gnu.org" , "libstdc++" Tested on Linux-PPC64. 2015-12-17 Ville Voutilainen PR libstdc++/68276 * src/c++11/ios.cc (_M_grow_words): Use nothrow new. * testsuite/27_io/ios_base/storage/11584.cc: Adjust. diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc index 4adc701..4241bef 100644 --- a/libstdc++-v3/src/c++11/ios.cc +++ b/libstdc++-v3/src/c++11/ios.cc @@ -121,9 +121,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__ix < numeric_limits::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) diff --git a/libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc b/libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc index 0c80795..ae680c7 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc @@ -26,14 +26,14 @@ 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); }