C++ Logo


Advanced search

Re: [std-proposals] delete p = nullptr;

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Wed, 21 Dec 2022 09:31:10 -0500
On Wed, Dec 21, 2022 at 6:52 AM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> On Tuesday, 20 December 2022 04:07:27 -03 Frederick Virchanza Gotham via Std-
> Proposals wrote:
> > Therefore when you see "delete p = nullptr;", irrespective of whether
> > you're familiar with operator
> > precedence, you know that it must be setting the pointer to null after
> > delete'ing it, because nothing
> > else makes sense.
> That is not a correct assumption.
> The problem is that if you're a reviewer and you're not familiar with the
> expression, you may think it does the opposite and be a no-op + memory leak.

Equally importantly, if you're doing a code review, and you see
something that might be correct or might be nonsense based on some
peculiar rule, that's something you should flag regardless of whether
it technically works.

Received on 2022-12-21 14:33:37