[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lack of return values not reported
From: |
Maurizio Loreti |
Subject: |
Re: Lack of return values not reported |
Date: |
22 May 2001 09:47:47 +0200 |
address@hidden (Kenton Varda) writes:
> For some reason, GCC often will not tell me when I forget to return a
> value from a non-void function. Even with -Wall, I get no indication of
> the problem. I can't imagine why this would be anything other than an
> error, but at least a warning would be very helpful. This is especially
> frustrating when, say, a function is supposed to return a string, and
> the caller just ends up segfaulting in some obscure STL function.
>
> I am currently using GCC 2.96 (via RedHat 7.1), but I have had this
> problem with 2.95 as well.
This does not happen for me.
address@hidden 33 $ cat foo.cc
int bar(void);
int main() {
return 0;
}
int bar(void) { }
address@hidden 34 $ g++ -Wall -o foo foo.cc
foo.cc: In function `int bar()':
foo.cc:7: warning: control reaches end of non-void function `bar()'
address@hidden 35 $
--
Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html
Univ. of Padova, Dept. of Physics - Padova, Italy address@hidden
The instructions said to use Windows 98 or better - so I installed FreeBSD.