public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114492] New: Invalid use of gcc_assert (notably in gcc/config/aarch64/aarch64-ldp-fusion.cc)
@ 2024-03-27  2:34 hp at gcc dot gnu.org
  2024-03-27  3:04 ` [Bug target/114492] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hp at gcc dot gnu.org @ 2024-03-27  2:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114492

            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 argument
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_true())

with:

bool x = 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 both
within gcc in gcc_assert and user-visible, for implementations of assert; say
__builtin_pure_p (X).  (The name is ripe to bike-shedding, just choosing a mix
of __builtin_constant_p and the "pure" attribute.)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-02 13:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27  2:34 [Bug target/114492] New: Invalid use of gcc_assert (notably in gcc/config/aarch64/aarch64-ldp-fusion.cc) hp at gcc dot gnu.org
2024-03-27  3:04 ` [Bug target/114492] " pinskia at gcc dot gnu.org
2024-03-27  3:06 ` pinskia at gcc dot gnu.org
2024-03-27 15:11 ` hp at gcc dot gnu.org
2024-04-02 13:50 ` acoplan at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).