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

Package: gcc-4.3; Maintainer for gcc-4.3 is Debian GCC Maintainers <debian-gcc@lists.debian.org>;

Reported by: Peter Lebbing <peter@digitalbrains.com>

Date: Sun, 15 Jun 2008 14:15:01 UTC

Severity: normal

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#486347; Package gcc-4.3. Full text and rfc822 format available.

Acknowledgement sent to Peter Lebbing <peter@digitalbrains.com>:
New Bug report received and forwarded. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Peter Lebbing <peter@digitalbrains.com>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: gcc-4.3: Superfluous warning when -std=c99/gnu99 and noreturn on main()
Date: Sun, 15 Jun 2008 16:13:26 +0200
-----BEGIN PGP SIGNED MESSAGE-----
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBSFUjg/qr/97I5g4/AQLOUgP9FCp0MWLfh38xBvNolcmV1Kk+eEMiycdO
KH2WB8BPvScE/OuL8/MKLt8QVFyro5Z87ZCYxhrTmRiHIdQ4D1bcA68yR+zwDjA4
NvF8Yp5AwZcNfq83rtWVS+SGm2KPTlpLtun6e+afzwKMuvSB4ssJxa56oOE2b+S/
Bqpkh9xBAZc=
=MxU0
-----END PGP SIGNATURE-----




Information forwarded to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#486347; Package gcc-4.3. Full text and rfc822 format available.

Acknowledgement sent to Bastian Blank <waldi@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>. Full text and rfc822 format available.

Message #10 received at 486347@bugs.debian.org (full text, mbox):

From: Bastian Blank <waldi@debian.org>
To: Peter Lebbing <peter@digitalbrains.com>, 486347@bugs.debian.org
Subject: Re: Bug#486347: gcc-4.3: Superfluous warning when -std=c99/gnu99 and noreturn on main()
Date: Sun, 15 Jun 2008 17:38:16 +0200
On Sun, Jun 15, 2008 at 04:13:26PM +0200, Peter Lebbing wrote:
> 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/.

Well, main returns always in a hosted environment.

> 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.

I doubt that you want a hosted compiler environment while building code
for such a device. Use -ffreestanding and/or use a different name then
main.

Bastian

-- 
Mind your own business, Spock.  I'm sick of your halfbreed interference.




Information forwarded to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#486347; Package gcc-4.3. Full text and rfc822 format available.

Acknowledgement sent to Peter Lebbing <peter@digitalbrains.com>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>. Full text and rfc822 format available.

Message #15 received at 486347@bugs.debian.org (full text, mbox):

From: Peter Lebbing <peter@digitalbrains.com>
To: Bastian Blank <waldi@debian.org>
Cc: 486347@bugs.debian.org
Subject: Re: Bug#486347: gcc-4.3: Superfluous warning when -std=c99/gnu99 and noreturn on main()
Date: Sun, 15 Jun 2008 20:03:36 +0200
Bastian Blank wrote:
> Well, main returns always in a hosted environment.

The bug reporter of bug #141015 used exit() on all occasions, I thought that
didn't count as a return? (just curiosity)

I think the noreturn attribute is quite overkill for normal computers
though, this in contrast to embedded development.

> I doubt that you want a hosted compiler environment while building code 
> for such a device. Use -ffreestanding and/or use a different name then 
> main.

I have to admit I might not fully understand what you mean. I looked at the
description of -ffreestanding; I'm under the impression you are talking
about a program that does not use standard libraries, whereas I'm talking
about development using avr-libc.

The avr-libc documentation has this to say about -ffreestanding:

> However, this also turns off all optimizations normally done by the
> compiler which assume that functions known by a certain name behave as
> described by the standard. E. g., applying the function strlen() to a
> literal string will normally cause the compiler to immediately replace
> that call by the actual length of the string, while with -ffreestanding,
> it will always call strlen() at run-time.

Doesn't sound like what I want.

Thanks for the reply,

Peter.

-- 
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




Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Apr 16 19:07:37 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.