From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9404 invoked by alias); 13 Oct 2003 22:19:18 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9395 invoked by uid 48); 13 Oct 2003 22:19:18 -0000 Date: Mon, 13 Oct 2003 22:19:00 -0000 From: "james at ittc dot ku dot edu" To: gcc-bugs@gcc.gnu.org Message-ID: <20031013221916.12603.james@ittc.ku.edu> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/12603] New: No return statement warning on function that never returns with -O3 X-Bugzilla-Reason: CC X-SW-Source: 2003-10/txt/msg00894.txt.bz2 List-Id: 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.