public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* -Wunused don't warn for exit
@ 2007-01-31  9:43 Gabriel Linder
  2007-01-31 15:30 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Gabriel Linder @ 2007-01-31  9:43 UTC (permalink / raw)
  To: gcc-help

Hello all,

I have a strange behaviour I can't explain with GCC (3.2.2), considering 
the following piece of code (exit.c) :

/* snip */
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
        0;
        printf;
        exit;
        exit(1);
        return 0;
}
/* snip */

When compiled with gcc -Wunused -Wunreachable-code exit.c I get these 
warnings :
exit.c: In function `main':
exit.c:6: warning: statement with no effect
exit.c:7: warning: statement with no effect

So GCC detects lines 6 and 7, that's ok. But why didn't it print a 
warning for lines 8 (exit with no args, equal to the value of exit 
function pointer, useless) and 10 (return 0 after exit, will never be 
executed) ?

This is the declaration of exit function (stdlib.h) :
__BEGIN_NAMESPACE_STD
extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
__END_NAMESPACE_STD

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: -Wunused don't warn for exit
  2007-01-31  9:43 -Wunused don't warn for exit Gabriel Linder
@ 2007-01-31 15:30 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2007-01-31 15:30 UTC (permalink / raw)
  To: Gabriel Linder; +Cc: gcc-help

Gabriel Linder <linder@jeuxvideo.com> writes:

> I have a strange behaviour I can't explain with GCC (3.2.2),

3.2.2 is pretty old.  The current version is 4.1.1.

> When compiled with gcc -Wunused -Wunreachable-code exit.c I get these
> warnings :
> exit.c: In function `main':
> exit.c:6: warning: statement with no effect
> exit.c:7: warning: statement with no effect

I get these warnings with current gcc:

foo5.c: In function ‘main’:
foo5.c:6: warning: statement with no effect
foo5.c:7: warning: statement with no effect
foo5.c:8: warning: statement with no effect
foo5.c:10: warning: will never be executed

which looks OK to me.

gcc 3.2.2 is no longer supported, so the bug will not be fixed in that
old release.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-01-31 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-31  9:43 -Wunused don't warn for exit Gabriel Linder
2007-01-31 15:30 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).