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.
Confirmed. W.
Was confirmed.
From Phil's regression hunter: Search converges between 2003-03-09-trunk (#240) and 2003-03 -10-trunk (#241). : Search converges between 2003-03-12-3.3 (#77) and 2003-03-13-3.3 (#78).
Fixing.
Subject: Bug 13394 CVSROOT: /cvs/gcc Module name: gcc Changes by: ebotcazou@gcc.gnu.org 2003-12-23 05:32:02 Modified files: gcc : ChangeLog toplev.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: noreturn-7.c Log message: PR optimization/13394 * toplev.c (rest_of_compilation): Move call to check_function_return_warnings right after the sibcall optimization pass. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2081&r2=2.2082 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&r1=1.852&r2=1.853 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3303&r2=1.3304 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/noreturn-7.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 13394 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: ebotcazou@gcc.gnu.org 2003-12-23 06:28:37 Modified files: gcc : ChangeLog toplev.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: noreturn-7.c Log message: PR optimization/13394 * toplev.c (rest_of_compilation): Move call to check_function_return_warnings right after the sibcall optimization pass. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.856&r2=1.16114.2.857 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.690.2.23&r2=1.690.2.24 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.344&r2=1.2261.2.345 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/noreturn-7.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg01868.html