This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/10048: Compiler doesn't catch failure to return a value - causes crashing code
- From: bangerth at dealii dot org
- To: cjc at cs dot brown dot edu, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 12 Mar 2003 21:28:41 -0000
- Subject: Re: c++/10048: Compiler doesn't catch failure to return a value - causes crashing code
- Reply-to: bangerth at dealii dot org, cjc at cs dot brown dot edu, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: Compiler doesn't catch failure to return a value - causes crashing code
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Wed Mar 12 21:28:41 2003
State-Changed-Why:
So what is the question? You are falling off the edge of
this function without a proper return statement. The standard
says to this (6.6.3.2):
Flowing off the end of a
function is equivalent to a return with no value; this results in
undefined behavior in a value-returning function
Undefined behavior is what you get here (a crash). If
you want the compiler to catch this, turn on warnings
which traps here.
I think there's not much more gcc can do for you here...
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10048