This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: missing return statement
- From: Robert Dewar <dewar at adacore dot com>
- To: Nathan Ridge <zeratul976 at hotmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 12 Mar 2009 19:56:26 -0400
- Subject: Re: missing return statement
- References: <BAY110-W315A19B2ABDCCF5C4572FA969F0@phx.gbl>
Nathan Ridge wrote:
Why does gcc not give an error about this?
If I compile with "-Wall", it will give a WARNING saying
"control reaches end of non-void function".
However, shouldn't it be an ERROR to return nothing
from a function that's supposed to return something?
Does this not result in undefined behaviour? Why goes gcc allow it?
Because the standard does not make this an error, you can't tell
if anyone needs a result, perhaps function is always called in
a void environment.
A warning is all you can get, always pay attention to warnings!
Thanks,
Nate.
_________________________________________________________________
Share photos with friends on Windows Live Messenger
http://go.microsoft.com/?linkid=9650734