From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 063353858D1E; Thu, 10 Feb 2022 22:07:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 063353858D1E From: "jason at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102586] [12 Regression] ICE in clear_padding_type, at gimple-fold.c:4798 since r12-3433-ga25e0b5e6ac8a77a Date: Thu, 10 Feb 2022 22:07:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jason at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created 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, 10 Feb 2022 22:07:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102586 --- Comment #16 from Jason Merrill --- Created attachment 52410 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52410&action=3Dedit sketch of vbase handling This is roughly what I had in mind, though it's algorithmically poor becaus= e it walks all the bases each time. But then it occurred to me that unless we know the complete object type, we don't know whether we're dealing with a base subobject, and risk clearing t= oo much: struct C1 { virtual void f() {} char d; }; // vfn to make non-layout-POD struct C2: C1 { char c; }; __attribute__((noipa)) void foo (C1 *q) { __builtin_clear_padding (q); } int main() { C2 c2; c2.c =3D 42; foo (&c2); if (c2.c !=3D 42) __builtin_abort(); } Because of this, I think we probably want __builtin_clear_padding to reject arguments that point to non-trivially-copyable type. And then we don't nee= d to worry about vbases.=