On Jan 30 2022, Jonathan Wakely via Gcc wrote:

> On Sun, 30 Jan 2022, 10:58 Jakub Jelinek, <ja...@redhat.com> wrote:
>
>> On Sun, Jan 30, 2022 at 10:50:56AM +0000, Jonathan Wakely wrote:
>> > We could put a trap instruction at the end of the function though, which
>> > would make the result a bit less arbitrary.
>> >
>> > I've come around to thinking that's preferable for cases like this.
>>
>> Depends on which exact cases.
>> Because for
>> int foo (int s) { if (s == 123) return 1; }
>> we want to optimize it into
>> return 1;
>> rather than if (s == 123) return 1; else __builtin_trap ();
>> For debugging we have -fsanitize=undefined
>
>
> What if we inserted the trap for -O0?

Note that in C it is not an error to fall through the end of a non-void
function if the caller does not use the return value.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Reply via email to