This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: egcs, RFC: patch for possible -Wmissing-noreturn warning
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: egcs, RFC: patch for possible -Wmissing-noreturn warning
- From: Martin Mares <mj at ucw dot cz>
- Date: Mon, 12 Oct 1998 09:52:43 +0200
- Cc: egcs at cygnus dot com
- References: <199810111726.NAA19753@caip.rutgers.edu>
Hello,
> Looking at these functions, they clearly fall off their ends. Eg:
>
> > static inline void
> > fde_insert (fde_accumulator *accu, fde *this_fde)
> > {
> > accu->linear.array[accu->linear.count++] = this_fde;
> > }
>
> So why is the test flagging them? Is there another bit I need to
> check besides:
> current_function_returns_null && current_function_returns_value ??
It is not as simple as it might look on the first sight. It's easy to prove
there exists _no_ algorithm distinguishing functions that really return.
Examples:
void x(void) { for(;;); } Doesn't return
void x(void) { int x; for(x=0; x<1000; x++); } Does return
void x(void) { float x; for(x=0; x<1e30; x++); } Doesn't return
There are three possible cases:
[1] Functions that contain no jumps. They always return and there is nothing
to check.
[2] Functions that always have a call to non-returning function before each
exit point. They are guaranteed not to return and they can be warned about
if they are not declared non-returning.
[3] Functions that contain jumps and don't fall into the previous category.
Since the Halting Problem is uncomputable, you cannot tell whether they
return or not which makes warnings of this case impossible.
Anyway, the [2] case seems to be interesting.
Have a nice fortnight
--
Martin `MJ' Mares <mj@ucw.cz> http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"Computers are useless. They can only give you answers." -- Pablo Picasso