From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47974 invoked by alias); 5 Nov 2015 15:22:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 47954 invoked by uid 89); 5 Nov 2015 15:22:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=unavailable version=3.3.2 X-HELO: mail-io0-f174.google.com Received: from mail-io0-f174.google.com (HELO mail-io0-f174.google.com) (209.85.223.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 05 Nov 2015 15:22:40 +0000 Received: by iody8 with SMTP id y8so92690550iod.1 for ; Thu, 05 Nov 2015 07:22:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=oFAtUPJSMSVObyEHCldEVzd6oa1yn+kqK9HXg4KuARs=; b=ILffe8FIrjWbo8YgayiuIjchDdpg9WMP9CarfLSczwBOnxfa7aMxt5Q1uJeV77Wa3+ IlFN8QBE/P3xEeEloNtKzdmjMlXT7A/0Q/jxuRqyWHQpG8uSeiV0UCATrJwvb+IRS51I cDYXksKU40ANPUcuTzgjDiQDCSYCa6J2bRutKMgWt+rpB6j0noobRrnO5onuMMG0Ha5c TXeV6vtGs1eapa8NZoSN2gXzaGr7awiZduqSbktSAhlGhabdwigoBb1Gi527+/vjoENw Zh8H3SQvrQ3rQttdx5Gt8pGl7bx8mOJEdAVUs4X7NuoSIOvSF4umFRRwX8+TvkfQ7U/S +bWw== X-Gm-Message-State: ALoCoQmJShk/yzLXHTi77RmWGduYyoTZm/rMB8sSmIu5IpFJbyd9L4WPMIAXoVunsREo7DnC1gmD MIME-Version: 1.0 X-Received: by 10.107.12.93 with SMTP id w90mr11837931ioi.110.1446736958395; Thu, 05 Nov 2015 07:22:38 -0800 (PST) Received: by 10.36.5.148 with HTTP; Thu, 5 Nov 2015 07:22:38 -0800 (PST) In-Reply-To: References: <1446554133-3090-1-git-send-email-aurelio.remonda@tallertechnologies.com> <56391843.1070807@gmail.com> Date: Thu, 05 Nov 2015 15:22:00 -0000 Message-ID: Subject: Re: [PATCH] Add configure flag for operator new (std::nothrow) From: Daniel Gutson To: Jonathan Wakely Cc: Martin Sebor , Aurelio Remonda , "libstdc++" , "gcc-patches@gcc.gnu.org" , daniel.gutston@tallertechnologies.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00475.txt.bz2 On Wed, Nov 4, 2015 at 3:20 AM, Jonathan Wakely wro= te: > On 4 November 2015 at 02:11, Daniel Gutson wrote: >> Since this is a nothrow new, we thought that probably the system >> might not be exceptions-friendly (such as certain embedded systems), >> so we wanted to provide the new_handler the ability to do something else >> other than trying to allocate memory and keep the function iterating. > > That could be done using an alternative overload of operator new > instead of altering the semantics of the standard one (that could be > provided as a GNU extension, for example). > >> In fact, our idea is that since the nothrow new can indeed return nullpt= r, >> let the new_handler do something else and leave the no-memory-consequence >> to the caller. >> This new flag enables just that. > > > The default configuration already allows the caller to deal with > allocation failure from the nothrow version of new, by not installing > a new-handler installed, and dealing with a null return value. How > would I use this alternative configuration? Since the behaviour only > changes when a new-handler is installed, presumably I'm meant to > install some kind of new-handler that does something else ... but > what? The patch should include documentation explaining when and how > to use this option. Real use cases: statistics and logging. It's a (one time) callback reporting that something went wrong, but not intended to fix things e.g. by attempting to free more memory. --=20 Daniel F. Gutson Chief Engineering Officer, SPD San Lorenzo 47, 3rd Floor, Office 5 C=C3=B3rdoba, Argentina Phone: +54 351 4217888 / +54 351 4218211 Skype: dgutson LinkedIn: http://ar.linkedin.com/in/danielgutson