From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A4B563858023; Fri, 11 Feb 2022 12:31:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4B563858023 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: Fri, 11 Feb 2022 12:31:50 +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: 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: Fri, 11 Feb 2022 12:31:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102586 --- Comment #21 from Jakub Jelinek --- Created attachment 52413 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52413&action=3Dedit gcc12-pr102586.patch Indeed, and when creating BIT_CAST_EXPR we actually verify those trivially_copyable_p types. This patch implements the rejection of pointers to non-trivially-copyable t= ypes with the exception of &var or &parm, because in those cases we know it is complete object type and so don't need to worry about it being just a subobject. I think the exception for that case is useful, so that users can still clear the padding bits on them, but the restriction means that they need to use t= he builtin directly or in a macro rather than through inline function. But the risks of clobbering real data otherwise is real. The other option would be just document that it shouldn't be called on non-trivially-copyable base classes and make it user's responsibility. For the and std::bit_cast uses it doesn't really matter.=