Superfluous warning when -std=c99/gnu99 and noreturn on main()
>Submitter-Id: net
>Originator: Agthorr <agthorr@barsoom.org>
>Organization: The Debian Project
>Confidential: no
>Synopsis:
>Severity: non-critical
>Priority: low
>Category: c
>Class: sw-bug
>Release: 3.2.1 (Debian) (Debian unstable)
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: i686
Configured with: /home/packages/gcc/3.2/gcc-3.2-3.2.1ds5/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
>Description:
[ Reported to the Debian BTS as report #141015.
Please CC 141015@bugs.debian.org on replies.
Log of report can be found at http://bugs.debian.org/141015 ]
[ rechecked with gcc-3.2.1 prerelease ]
The following program generates a superfluous warning when compiled
with -std=c99 or -std=gnu99.
------------------------------------------------------------------------
#include <stdlib.h>
int main (void) __attribute__ ((noreturn));
int main (void)
{
exit(1);
}
------------------------------------------------------------------------
volition:~/tmp$ gcc-3.0 -std=c99 -c test.c
test.c: In function `main':
test.c:6: warning: function declared `noreturn' has a `return' statement
volition:~/tmp$
------------------------------------------------------------------------
Obviously, this warning is bogus since there is no return statement
anywhere in the program :> The warning is not produced by gcc 2.95.4
nor in the default -std=gnu89 mode.
Although this example is trivial, I encountered the bug in an actual
program that depends on -std=gnu99 (since C99 features are used). In
the program, main() starts an event loop which never directly returns;
the program exits by calling exit().
>How-To-Repeat:
>Fix:
Reply to: