From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BF27E3858C3A; Thu, 10 Feb 2022 15:29:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF27E3858C3A From: "jakub 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 15:29:53 +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: jakub 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: 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 15:29:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102586 --- Comment #10 from Jakub Jelinek --- So, on struct C0 {}; struct C1 {}; struct C2 : C1, virtual C0 {}; struct C3 : virtual C2, C1 { virtual int foo () { return 1; } }; struct C6 { char c; }; struct C7 : virtual C6, virtual C3, C1 { virtual int foo () { return 4; } }; struct C8 : C7 { virtual int foo () { return 5; } }; __attribute__((noipa)) void foo (C8 *q) { __builtin_clear_padding (q); } C8 c8; C7 c7; void bar () { c8.c =3D 42; c7.c =3D 43; } distilled from the testcase in the patch, c8.c is at 9 bytes into c8, while c7.c is at 8 bytes into c7, so that is likely the reason why the code consi= ders both byte at offset 8 and 9 as non-padding - the first FIELD_DECL in C8 is one with C7 type (32 byte long like C8) but the field size is 9 bytes, so t= hat the __builtin_clear_padding code thinks the first 9 bytes are non-padding, virtual table pointer inside of C2, then empty type C1 at off 8, then C6 at= off 8 with the c 1-byte field, then C3 at offset 16 with 9 byte size but all th= is is already outside of the size of FIELD_DECL with C7 type. But C8 has a FIELD_DECL with C6 type at off 9...=