This is the mail archive of the
mailing list for the GCC project.
Re: Optimizing away deletion of null pointers with g++
- From: Oleg Endo <oleg dot endo at t-online dot de>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>, Daniel Langr <daniel dot langr at gmail dot com>, gcc at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>
- Date: Wed, 16 Aug 2017 23:27:40 +0900
- Subject: Re: Optimizing away deletion of null pointers with g++
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com> <firstname.lastname@example.org>
On Wed, 2017-08-16 at 13:30 +0200, Paolo Carlini wrote:
> I didn't understand why we don't already handle the easy case:
> constexpr int* ptr = nullptr;
> delete ptr;
What about overriding the global delete operator with some user defined
implementation? Is there something in the C++ standard that says the
invocation can be completely omitted, i.e. on which side of the call
the nullptr check is being done?
One possible use case could be overriding the global delete operator to
count the number of invocations, incl. for nullptr. Not sure how
useful that is though.