This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bug egcs 1.1.1


Hi,

nradisch@panix.com:
> If a function that should return a value does not, no error or warning
> is given. This frequently results in hard to find program crashes.
> 
It's not the problem of GCC if you don't turn on any warnings.

... was my first impression. Unfortunately, your code sometimes really
_does_ not cause any warning to be emitted even under -W.


<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
int foo(void)
{
   extern int bar(void);
   int something = bar();
   if (something == 5) return 12;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

With 2.95-current:

$ gcc -c -Wall /tmp/foo.c -o /tmp/foo.o
/tmp/foo.c: In function `foo':
/tmp/foo.c:6: warning: control reaches end of non-void function
$ gcc -c -W /tmp/foo.c -o /tmp/foo.o
/tmp/foo.c: In function `foo':
/tmp/foo.c:6: warning: this function may return with or without a value
$ gcc -O1 -c -W /tmp/foo.c -o /tmp/foo.o
/tmp/foo.c: In function `foo':
/tmp/foo.c:6: warning: this function may return with or without a value
$ gcc -O2 -c -W /tmp/foo.c -o /tmp/foo.o
/tmp/foo.c: In function `foo':
/tmp/foo.c:6: warning: this function may return with or without a value
$ gcc -O3 -c -Wall /tmp/foo.c -o /tmp/foo.o
/tmp/foo.c: In function `foo':
/tmp/foo.c:6: warning: control reaches end of non-void function
$ gcc -O3 -c -W /tmp/foo.c -o /tmp/foo.o
$ ## note: NO output here

The "-O3 -W" case doesn't look right...

-- 
Matthias Urlichs  |  noris network GmbH   |   smurf@noris.de  |  ICQ: 20193661
The quote was selected randomly. Really.    |      http://www.noris.de/~smurf/
-- 
Happy hacking.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]