From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22070 invoked by alias); 19 Feb 2016 21:45:23 -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 22048 invoked by uid 89); 19 Feb 2016 21:45:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=lorenzo, Lorenzo, spd, Crdoba X-HELO: mail-ig0-f181.google.com Received: from mail-ig0-f181.google.com (HELO mail-ig0-f181.google.com) (209.85.213.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 19 Feb 2016 21:45:20 +0000 Received: by mail-ig0-f181.google.com with SMTP id g6so48704480igt.1 for ; Fri, 19 Feb 2016 13:45:20 -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-transfer-encoding; bh=8boptZb9elo2gCCOrvyvBleyqny1lYeswpm6PpTpRGI=; b=fDpNTDf3JEkBU+4x1Nt5Xl2D0laDhuOqA9qtfqT475Bvf2Wj/yO4mthmXVD5WNtT1D NIyiIj7L6bY1Z8xZIyp1kOyc5S3QbUWUPkuDD6adUkhw1Zu4Pip6VyFik7XBQ4s20Lym 8yakNG1PIW6CfiziCjSHlvRKrVtOF+pvDCHFRIdg3h7k6c7+VkUOOAPf/OPOte71NzEU WnNDNW43ePQqeLaD/BXjKafFwpBHAon7iTY1uHPaU42Q60JtuJyK6P21bsSYZgk4B5kh iDiFcA/iaVfarkglVm41nNHdbiZNNZp8SwN/fhzFYYKF1D6/jJJP0qfuVys3ql4j5LMJ ZuzQ== X-Gm-Message-State: AG10YOQPfX3M0OHRYtis/NAdGpizYQv/eTt4Lb8pjy7eBR5cB2Ke6nKvABUsx71e4xA7gQF1ezKSGAV7v1JpNo4R MIME-Version: 1.0 X-Received: by 10.50.155.5 with SMTP id vs5mr11435910igb.83.1455918318891; Fri, 19 Feb 2016 13:45:18 -0800 (PST) Received: by 10.36.5.148 with HTTP; Fri, 19 Feb 2016 13:45:18 -0800 (PST) In-Reply-To: <20151110131014.GC2937@redhat.com> References: <1446554133-3090-1-git-send-email-aurelio.remonda@tallertechnologies.com> <56391843.1070807@gmail.com> <563C79EB.7090302@gmail.com> <20151110131014.GC2937@redhat.com> Date: Fri, 19 Feb 2016 21:45:00 -0000 Message-ID: Subject: Re: [PATCH] Add configure flag for operator new (std::nothrow) From: Daniel Gutson To: Jonathan Wakely Cc: Pedro Alves , Jonathan Wakely , Martin Sebor , Aurelio Remonda , "libstdc++" , "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg01395.txt.bz2 On Tue, Nov 10, 2015 at 10:10 AM, Jonathan Wakely wrot= e: > On 06/11/15 09:59 +0000, Pedro Alves wrote: >> >> On 11/06/2015 01:56 AM, Jonathan Wakely wrote: >>> >>> On 5 November 2015 at 23:31, Daniel Gutson >> >> >>>> The issue is, as I understand it, to do the actual work of operator >>>> new, i.e. allocate memory. It should force >>>> us to copy most of the code of the original code of operator new, >>>> which may change on new versions of the >>>> STL, forcing us to keep updated. >>> >>> >>> It can just call malloc, and the replacement operator delete can call >>> free. >>> >>> That is very unlikely to need to change (which is corroborated by the >>> fact that the default definitions in libsupc++ change very rarely). >> >> >> Or perhaps libsupc++ could provide the default operator new under >> a __default_operator_new alias or some such, so that the user-defined >> replacement can fallback to calling it. Likewise for op delete. that would allow us to overload operator new as something like this: void* operator new ( std::size_t count, const std::nothrow_t& tag) noexcept(true) { const auto old_handler =3D std::set_new_handler(nullptr); const auto ret =3D __default_operator_new(count, tag); std::set_new_handler(old_handler); return ret; } This is a non-iterating operator new. This additional user defined operator new would be possible: void* operator new ( std::size_t count, const std::nothrow_t& tag) noexcept(true) { const auto old_handler =3D std::set_new_handler(nullptr); const auto ret =3D __default_operator_new(count, tag); std::set_new_handler(old_handler); if (ret =3D=3D nullptr && old_handler !=3D nullptr) old_handler(); return ret; } So I like the idea. > > > That could be useful, please file an enhancement request in bugzilla > if you'd like that done. --=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