13394 – [3.3/3.4 Regression] noreturn attribute ignored on recursive invokation (original) (raw)
Description Carlo Wood 2003-12-13 15:33:35 UTC
A real-life program gave me an erroneous warning '`noreturn' function does return', while it is impossible that it returns and more importantly: it indeed doesn't return: it is a logical error to ignore a recursively invokated functions noreturn attribute when determining the validness of that noreturn attribute.
Now, a possible warning would be: 'noreturn' function might caught stack overflow due to self-invokation', but the keyword there is MIGHT. And I think that the explicit existance of the noreturn' attribute
should give us the favour of gcc's doubt: this function
will exit somehow. It CERTAINLY doesn't return.
Example snippet:
int f(void) attribute ((noreturn)); void _exit(int status) attribute ((noreturn));
int z = 0;
int f() { if (++z > 10) _exit(0); f(); }
gcc-cvs-3.4 -Wall -O2 -c noreturn.c noreturn.cc: In function
int f()': noreturn.cc:11: warning:noreturn' function does return
This is a regression: gcc 3.2.3 and all previous versions of gcc (tried 2.95.3, 2.96, 3.0.4, 3.1.1 and 3.2.x) do not give the warning.