This is the mail archive of the
gcc@gcc.gnu.org
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: <945ec347-76c2-0fd8-a621-9e1ae22ae38b@gmail.com> <8d121cc3-e16d-66a3-2e3d-82c554dee4c4@oracle.com>
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.
Cheers,
Oleg