[Bug c/12603] New: No return statement warning on function that never returns with -O3

james at ittc dot ku dot edu gcc-bugzilla@gcc.gnu.org
Mon Oct 13 22:19:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603

           Summary: No return statement warning on function that never
                    returns with -O3
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: james at ittc dot ku dot edu
                CC: gcc-bugs at gcc dot gnu dot org,james at ittc dot ku dot
                    edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

The following function compiles without warning at optimization level -O2 or
below.  With -Wall -O3, gcc says:

noreturn.c: In function `this_function_never_returns':
noreturn.c:5: warning: no return statement in function returning non-void

This happens with gcc 3.2.2 - 3.3.1, at least.

int
this_function_never_returns ()
{
  for (;;);
}

This is an extremely stripped down version of a problem with XEmacs and
Fcommand_loop_1, which must be declared to return a Lisp_Object (since it is a
Lisp-visible function), but which contains an infinite loop.  The obvious
solution of putting a return statement at the end causes some compilers to
complain about unreachable code.  Adding __attribute__ ((noreturn)) did not make
the warning go away.



More information about the Gcc-bugs mailing list