From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F14413858C78; Mon, 14 Mar 2022 23:58:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F14413858C78 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103483] [12 regression] context-sensitive ranges change triggers stringop-overread Date: Mon, 14 Mar 2022 23:58:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org 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: 12.0 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: Mon, 14 Mar 2022 23:58:28 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103483 --- Comment #23 from Martin Sebor --- (In reply to Richard Biener from comment #22) Your question may have been rhetorical but to be explicit, the real differe= nce is hidden in the implementation (which is why these warnings can sometimes = seem inconsistent). GCC doesn't warn for the second test case (copied below) because it only considers the lower bound of len's range: int a[2]; void foo (unsigned len) { if (len =3D=3D 1 || len =3D=3D 20) __builtin_memset (a, 0, len); } But the warning would trigger if GCC decided it was profitable to split the memset call into two statements: int a[2]; void foo (unsigned len) { if (len =3D=3D 1) a[0] =3D 0; else if (len =3D=3D 20) __builtin_memset (a, 0, 20); } I suspect most users (though not all, otherwise this report would have never been raised) would consider a warning valid and helpful for the source code= .=20 But if instead of (len =3D=3D 1 || len =3D=3D 20) the condition were to be = written in terms of a relational expression (like len <=3D N) where N were greater tha= n or even equal to sizeof (a) + 1, I'd expect complaints about the warning being= a false positive because GCC can't "know" that len =3D=3D N necessarily holds= .=