Bug 13394 - [3.3/3.4 Regression] noreturn attribute ignored on recursive invokation
Summary: [3.3/3.4 Regression] noreturn attribute ignored on recursive invokation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.3.3
Assignee: Eric Botcazou
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2003-12-13 15:33 UTC by Carlo Wood
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-12-15 17:28:33


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.
Comment 1 Wolfgang Bangerth 2003-12-15 09:27:06 UTC
Confirmed. 
W. 
Comment 2 Carlo Wood 2003-12-15 17:28:33 UTC
Was confirmed.
Comment 3 Andrew Pinski 2003-12-16 16:27:04 UTC
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).
Comment 4 Eric Botcazou 2003-12-20 10:56:58 UTC
Fixing.
Comment 5 GCC Commits 2003-12-23 05:32:10 UTC
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

Comment 7 Eric Botcazou 2003-12-23 06:29:31 UTC
See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg01868.html