[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#486347: gcc-4.3: Superfluous warning when -std=c99/gnu99 and noreturn on main()

Hash: SHA1

Package: gcc-4.3
Severity: normal

This bug report is actually a duplicate of bug #141015, which was filed
against gcc-3.0. The bug was never fixed because it was deemed unimportant:
when the bug reporter used a different combination of settings, he no longer
got the warning. However, he also no longer got the /functionality/.

The following code generates the warning:

- ---- test.c ----

int main () __attribute__ ((noreturn));

int main () {
  for (;;) {
    // Endless loop

- --- End of test.c ---

$ gcc -std=gnu99 test.c -o test
test.c: In function ‘main’:
test.c:7: warning: function declared ‘noreturn’ has a ‘return’ statement

This is because C99 implicitly adds a return 0; at the end of main().

This bug is still a bit bothersome to me. When I compile a C program for use
on a microcontroller with the package gcc-avr, the noreturn attribute on
main() actually triggers better optimisation, resulting in more optimal
stack usage. This can be a big benefit on a device with usually between 128
and 1024 bytes of RAM. Most programs on these devices never return from
main(). Very often an endless loop like above is used, or something similar.

Please consider fixing this bug for users like me who'd rather not see a
confusing warning message on compilation.

I did not file this bug against gcc-avr because the problem doesn't seem to
be there. However, for your information, here's my current package information:

Package: gcc-avr
Version: 1:4.3.0-2

Versions of packages gcc-avr depends on:
ii  binutils-avr              2.18-3         Binary utilities supporting Atmel'
ii  libc6                     2.7-10         GNU C Library: Shared libraries
ii  libgmp3c2                 2:4.2.2+dfsg-3 Multiprecision arithmetic library
ii  libmpfr1ldbl              2.3.1.dfsg.1-2 multiple precision floating-point

Thanks for your time,

Peter Lebbing.

- -- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (900, 'testing'), (100, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.24-1-amd64 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

- --
I'm using the GNU Privacy Guard (GnuPG) in combination with Enigmail.
You can send me encrypted mail if you want some privacy.
My key is available at http://wwwhome.ewi.utwente.nl/~lebbing/pubkey.txt
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


Reply to: