From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 28DA53858C50; Tue, 25 Apr 2023 16:30:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28DA53858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682440230; bh=Q7qsf1ekKxeCl94+kEP6vATJ3EJYZkGv4HO2o/M8B8o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nn0qhOaZvQZOXZ6vp4zYvpjAsbuz2z1PX1dXO0Qi1fiVUFd+lght8kD6EJLQDBsNS 7P6S2IuypVCEE5YqEhWqkNiPEkdAhT9vXOH+6BQtHFQYGtViKnu1xmYgeoAEdIjHjf xRFKbb9aHKFzrLOCmO+qY6FqXUvOpykBgp4oHDbE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105523] Wrong warning array subscript [0] is outside array bounds Date: Tue, 25 Apr 2023 16:30:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: saaadhu 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=3D105523 --- Comment #24 from Andrew Pinski --- (In reply to LIU Hao from comment #22) > Yes, GCC should be told to shut up about dereferencing artificial address > values. NO. Take: ``` static inline int f(int *a) { return a[10]; } int g() { return f(0); } ``` The warning is there for the above case really (and similar ones with struct offsets). Where you originally have a null pointer and have an offset from there; by the time the warning happens, the IR does not know if it was originally from an offset of a null pointer or if the value was written in.= The paramater is there to "tune" the heurstic to figure out if it is null point= er deference or if it is some real (HW) address. Maybe -fno-delete-null-pointer-checks should imply --param=3Dmin-pagesize=3D0, th= ough some folks want the warning indepdent of trying to delete null pointer chec= ks.=