From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EB5E7385AC31; Wed, 17 Nov 2021 22:34:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB5E7385AC31 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103292] [12 regression] xorg-server-1.20.13 -Werror=array-bounds false positive on unions Date: Wed, 17 Nov 2021 22:34:12 +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: RESOLVED X-Bugzilla-Resolution: DUPLICATE 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: resolution component blocked cc 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: Wed, 17 Nov 2021 22:34:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103292 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |DUPLICATE Component|c |middle-end Blocks| |56456 CC| |jeffreyalaw at gmail dot c= om --- Comment #3 from Martin Sebor --- The originally intended purpose of this instance of -Warray-bounds was to w= arn for accesses to smaller buffers by larger lvalues, like in this function: struct A { int i; }; struct B { long j; }; struct B* make_B_from_A (const struct A *p) { struct B *q =3D __builtin_malloc (sizeof *p); // should be sizeof *q q->j =3D p->i; return q; } Here a warning should be issued regardless of whether -fstrict-aliasing is = in effect because the access is out of bounds. That the warning also triggers= in instances when the problem isn't one of an out-of-bounds access but rather = an aliasing violation was incidental (i.e., I didn't set out with that as a go= al), but because -Wstrict-aliasing in GCC is very limited, seemed like a bonus. So an argument could be (and in pr98503 in fact was) made that the instance= s of -Warray-bounds where the ultimate access is strictly in bounds should be replaced by one of -Wstrict-aliasing, which is enabled only when -fstrict-aliasing is in effect. I agreed and submitted a patch to do that: https://gcc.gnu.org/pipermail/gcc-patches/2021-January/564483.html Regrettably, the change was rejected. I CC the reviewer for his comments. *** This bug has been marked as a duplicate of bug 98503 *** Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56456 [Bug 56456] [meta-bug] bogus/missing -Warray-bounds=