From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7FB023857C4F; Thu, 26 Nov 2020 01:37:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FB023857C4F From: "peter at int19h dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97976] Optimization relating to NULL pointer assumptions in gcc 9.1 Date: Thu, 26 Nov 2020 01:37:40 +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: 9.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: peter at int19h dot net X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2020 01:37:40 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97976 --- Comment #10 from Peter Bisroev --- Jonathan, thank you so much for your explanation. As soon as I read it, it = all started to make sense. >You cannot increment or decrement a pointer past the end of an array (exce= pt the one past the end position). Yes of course, that is perfectly reasonable. And unless I am mistaken, the examples that I have provided do not do that directly because as the "array= " in those examples starts at address 0 as can be possible in some embedded syst= ems. But with the knowledge about how by default gcc treats a pointer to address= 0 everything can be perfectly explained. >GCC assumes there is no object at address zero, see the documentation for = -fdelete-null-pointer-checks Thank you for pointing this flag out to me. After reading its description a= nd searching a bit I can see that I am not the only one that got caught off gu= ard with this as shown in these links: * https://gcc.gnu.org/legacy-ml/gcc-patches/2015-04/msg00790.html * https://gcc.gnu.org/legacy-ml/gcc-patches/2007-03/msg01968.html * https://lkml.org/lkml/2018/4/4/601 * https://reviews.llvm.org/D47894 I will definitely go through gcc man page again to see if there is anything else that we should pay attention to. Once again, thank you for taking the time to explain all of this!=