This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: false 'noreturn' function does return warnings
- From: Ian Lance Taylor <iant at google dot com>
- To: "Zack Weinberg" <zackw at panix dot com>
- Cc: "Ralf Baechle" <ralf at linux-mips dot com>, gcc at gcc dot gnu dot org
- Date: 06 Feb 2007 16:14:30 -0800
- Subject: Re: false 'noreturn' function does return warnings
- References: <eb97335b0702061532g4fc574f4r3bf423d24b1d2630@mail.gmail.com>
"Zack Weinberg" <zackw@panix.com> writes:
> Back in 2000 I wrote a really simple patch that caused gcc to treat an
> ASM_OPERANDS that clobbered "pc" as a control flow barrier, exactly
> for this problem.
>
> http://gcc.gnu.org/ml/gcc-patches/2000-01/msg00190.html
>
> I still think it was a good idea, but at the time it was received
> unenthusiastically. I especially think "just use __builtin_trap()"
> misses the mark - at least some variants of the Linux kernel's BUG()
> macro, for instance, want to stick annotations in the assembly stream,
> which you cannot do with __builtin_trap...
I think we should just introduce __builtin_unreachable(), as others
have suggested. I think that is more consonant with our usual
approach to these issues.
I also think it would be good to have one option affecting it: turn
__builtin_unreachable() into an abort(), or turn it into a "cannot be
reached" marker. I think the former should be the default at -O0, the
latter at -O1 and above.
Note that a "cannot be reached" marker permits further optimization to
delete code which leads up to it. Actually implementing that further
optimization may call for adding appropriate warnings, probably
controlled by -Wunreachable-code.
Ian