From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 64CCD38346BB; Fri, 22 Jul 2022 07:09:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64CCD38346BB From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106389] [11/12/13 Regression] IPA modref breaks Safe Bitfields in C++ Date: Fri, 22 Jul 2022 07:09:10 +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: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc component 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: Fri, 22 Jul 2022 07:09:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106389 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org Component|ipa |c++ --- Comment #3 from Richard Biener --- There's a similar rule in C and we simply don't implement that - it's a "st= upid rule" given there's no good way to implement it. Well. -fno-strict-aliasi= ng. For GCC the allowed way is to access the common initial sequence through the _union_ type. Thus union U { struct A { int i; } a; struct B { int i; float f; } b; }; union U *p; p->a.i =3D 1; .. =3D p->b.i; // OK B *b =3D &p->b; ... =3D b->i; // not OK IPA modref simply makes this issue more visible (this across function boundary). Note the C rule doesn't involve unions but consider A *a =3D &p->a; a->i =3D 1; ... =3D b->i; I read the C++ rule as if that were allowed as well (*a could be inside a union, who knows - the union declaration might not even be visible in the TU!). For the rule to take effect the frontend needs to mark each access that falls under the rule as to have alias-set zero.=