From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EC4353858C2F; Wed, 17 May 2023 17:53:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC4353858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684345986; bh=+R0P6XU2VimlRcrTshAvHxkevXiI9fduFpZ8wgducb4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=upCRlIDoBq2ysGqwnsXKsNB5HkNL2lCHiIVkT1RhpqFrm2MNwQwK0AASjRXRwljjs 8tfrybzrCdD//l1D8t566m3nVNpmVxUZVZ0ngozn+mJM2HkXl+1PTkleIP27OVuQT4 g08m7nMC97kcyUkFJ4yJE01SoeOPOBdHQeeT9Pz8= From: "hiraditya at msn dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/87628] Redundant check of pointer when operator delete is called Date: Wed, 17 May 2023 17:53:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: hiraditya at msn dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D87628 --- Comment #5 from AK --- As per: https://en.cppreference.com/w/cpp/memory/new/operator_delete """ In all cases, if ptr is a null pointer, the standard library deallocation functions do nothing. If the pointer passed to the standard library deallocation function was not obtained from the corresponding standard libr= ary allocation function, the behavior is undefined. """ So it should be fine to remove the check `if(p)`=