abort() missing return-address => useless core file
Grant Edwards
grant.b.edwards at gmail.com
Mon Nov 21 18:07:19 UTC 2011
On 2011-11-20, Mike Frysinger <vapier at gentoo.org> wrote:
> it also introduces wrong warnings to valid code:
> int foo(int j) {
> int i;
> if (j < 100)
> abort();
> else
> i = 100;
> return j - i;
> }
>
> w/out noreturn attribute, "i" gets warned about because it's used
> uninitialized.
Not for me it doesn't.
I tried gcc 3.4.6, 4.4.5, 4.4.6, and 4.5.3. No warnings about i being
uninitialized.
Even if it did generate a warning when you replace abort() with some
other function call, gcc already knows that abort() doesn't return.
>From the gcc info page:
A few standard library functions, such as abort' and exit',
cannot return. GCC knows this automatically.
For example take the code below:
extern void abort(void);
int bar(int j)
{
j += 1;
abort();
}
That compiles fine with no warning. If you change the name of "abort"
to something else, then you do get a warning about control reaching
the end of a non-void function. Gcc knows that abort() doesn't
return. Adding the noreturn attribute does two things: 1) breaks
traceback in core files 2) saves a handful of bytes out of a million
or so
> yes, this is a contrived example,
It's not an example at all. It doesn't demonstrate the need for the
noreturn attribute.
--
Grant Edwards grant.b.edwards Yow! INSIDE, I have the
at same personality disorder
gmail.com as LUCY RICARDO!!
More information about the uClibc
mailing list