public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104642] New: Add __builtin_trap() for missing return at -O0
@ 2022-02-22 14:47 redi at gcc dot gnu.org
  2022-02-22 15:16 ` [Bug c++/104642] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-22 14:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104642
           Summary: Add __builtin_trap() for missing return at -O0
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

Again and again and again users are surprised (and often angry) about the
effects of a missing return in C++. It's undefined behaviour but that doesn't
stop bug reports like PR 104635 and questions like
https://gcc.gnu.org/pipermail/gcc/2022-January/238200.html

Users expect the undefined behaviour for a missing return to be "semi-defined".
We should just make it trap at -O0, then at least we can tell them that for
unoptimized code, the result is guaranteed to crash. With optimisation, it's
still undefined and can invalidate all their assumptions.

As I said in https://gcc.gnu.org/pipermail/gcc/2022-January/238204.html

What if we inserted the trap for -O0?

1. Not everybody uses ubsan even when they should use it.

2. The code can use unreachable annotations if it really needs to leave
some paths unhandled, but really can't live with the branch and trap
instructions. (The C++ standard is getting std::unreachable and std::assume
to do that in a portable way, so there is less excuse for not doing it).

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

end of thread, other threads:[~2022-06-22 13:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 14:47 [Bug c++/104642] New: Add __builtin_trap() for missing return at -O0 redi at gcc dot gnu.org
2022-02-22 15:16 ` [Bug c++/104642] " rguenth at gcc dot gnu.org
2022-02-24  0:48 ` pinskia at gcc dot gnu.org
2022-03-03 16:35 ` mpolacek at gcc dot gnu.org
2022-03-03 17:08 ` redi at gcc dot gnu.org
2022-03-11 20:44 ` redi at gcc dot gnu.org
2022-06-09 20:48 ` jason at gcc dot gnu.org
2022-06-10 19:42 ` jason at gcc dot gnu.org
2022-06-22 13:01 ` cvs-commit at gcc dot gnu.org
2022-06-22 13:18 ` jason 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).