This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Add configure flag for operator new (std::nothrow)
- From: Daniel Gutson <daniel dot gutson at tallertechnologies dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: Martin Sebor <msebor at gmail dot com>, Aurelio Remonda <aurelio dot remonda at tallertechnologies dot com>, "libstdc++" <libstdc++ at gcc dot gnu dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 5 Nov 2015 15:01:22 -0300
- Subject: Re: [PATCH] Add configure flag for operator new (std::nothrow)
- Authentication-results: sourceware.org; auth=none
- References: <1446554133-3090-1-git-send-email-aurelio dot remonda at tallertechnologies dot com> <56391843 dot 1070807 at gmail dot com> <CAF5HaEVeD4G1Mj8GwbpLyZ8V+GWNRAy1=5qbfVHgrZ=GpkbHbg at mail dot gmail dot com> <CAH6eHdQ_8cL8rqsX5u3NrNouf6E2_LtRPQ5F-V-rgTQ3FZTRug at mail dot gmail dot com> <CAF5HaEX5Ju0uXcFP4cLRvh_wWOBaqezbM6WdNUFp+CbzzKNjdg at mail dot gmail dot com> <CAH6eHdRf296VZwDaz8cS742RKEWid76un6-7ogxyzcTyWzj=rw at mail dot gmail dot com>
On Thu, Nov 5, 2015 at 2:11 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 5 November 2015 at 20:52, Daniel Gutson wrote:
>> 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.
>
> Why can't that be done by replacing operator new with a user-defined
> function, instead of modifying the default one?
>
> A program that wants to make use of the altered semantics is
> non-portable because it relies on a custom libstdc++ configuration
> option, and has to install a custom new-handler that relies on the
> altered libstdc++ behaviour. Replacing operator new to do the logging
> is portable and requires no custom configuration.
>
> (I'm not rejecting the patch, but am still trying to make sure it's a
> useful change.)
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.
This is important when having legacy code that uses operator new (but
doesn't use a new_handler),
--
Daniel F. Gutson
Chief Engineering Officer, SPD
San Lorenzo 47, 3rd Floor, Office 5
CÃrdoba, Argentina
Phone: +54 351 4217888 / +54 351 4218211
Skype: dgutson
LinkedIn: http://ar.linkedin.com/in/danielgutson