From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D58DB385843A; Wed, 27 Mar 2024 02:34:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D58DB385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711506872; bh=pn6bcciiMNldAoSCjukzLrACbOzjej1RVjTU0BZOtd4=; h=From:To:Subject:Date:From; b=l1XCA6IP+zwHIKC6x0wqC1yNZenKApE8YpBf3NC8gQa3O9W/CCTekS48ZTFUBTpoH Y4aABxPXp90gYJaZEKrol9fFbGxV97jRRJSPtfP8zCLDqg4Uc8Hg/Ur9RH8MFpjvHj h2/vC77KiZS63C2sVAwY6TFEHOz/4izliT5r4SQo= From: "hp at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114492] New: Invalid use of gcc_assert (notably in gcc/config/aarch64/aarch64-ldp-fusion.cc) Date: Wed, 27 Mar 2024 02:34:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hp at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone cf_gcctarget Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114492 Bug ID: 114492 Summary: Invalid use of gcc_assert (notably in gcc/config/aarch64/aarch64-ldp-fusion.cc) Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hp at gcc dot gnu.org CC: acoplan at gcc dot gnu.org Target Milestone: --- Target: aarch64 I've noticed invalid uses of gcc_assert in gcc/config/aarch64/aarch64-ldp-fusion.cc. Please be advised that the argum= ent is *not* evaluated with release checking; I believe most uses can be cured = by breaking out the call; i.e. replacing an invalid call: gcc_assert (function_that_needs_to_be_called_but_most_certainly_returns_tru= e()) with: bool x =3D function_that_needs_to_be_called_but_most_certainly_returns_true= (); gcc_assert (x). (Probably not the only file, just the one I've been looking at, for reasons, and I thought better enter a bug report, just not going to fix it myself.) Incidentally, I think "we" ought to add something to gcc that automatically checks and warns for such invalid use. There may be a need to implement a builtin to check that an expression X does not have side-effects, for use b= oth within gcc in gcc_assert and user-visible, for implementations of assert; s= ay __builtin_pure_p (X). (The name is ripe to bike-shedding, just choosing a = mix of __builtin_constant_p and the "pure" attribute.)=