public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/10048: Compiler doesn't catch failure to return a value - causes crashing code
@ 2003-03-12 21:36 Christian Convey
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Convey @ 2003-03-12 21:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/10048; it has been noted by GNATS.

From: Christian Convey <cjc@cs.brown.edu>
To: bangerth@dealii.org, cjc@cs.brown.edu, gcc-bugs@gcc.gnu.org,
   gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/10048: Compiler doesn't catch failure to return a value -
 causes crashing code
Date: Wed, 12 Mar 2003 16:30:28 -0500

 My apologies for misunderstanding the language.
 
 Thanks for your help.
 
 - Christian
 
 bangerth@dealii.org wrote:
 > 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
 
 -- 
 Christian Convey
 Sr. Software Engineer
 Computer Science Dept.,
 Brown University
 


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

* Re: c++/10048: Compiler doesn't catch failure to return a value - causes crashing code
@ 2003-03-12 21:28 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-03-12 21:28 UTC (permalink / raw)
  To: cjc, gcc-bugs, gcc-prs, nobody

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


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

* c++/10048: Compiler doesn't catch failure to return a value - causes crashing code
@ 2003-03-12 20:36 cjc
  0 siblings, 0 replies; 3+ messages in thread
From: cjc @ 2003-03-12 20:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10048
>Category:       c++
>Synopsis:       Compiler doesn't catch failure to return a value - causes crashing code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 12 20:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Christian Convey
>Release:        3.2.2
>Organization:
>Environment:
Interim Debian Linux build. Base kernel = 2.4.18
Athlon XP 1800+, 512 MB ram

gcc 3.2.2, built with:
--enable-shared --enable-threads --enable-long-long
Thread model: posix
>Description:
The code I've attached compiles without any complaint.

g++ x.C; a.out


However, if it's run unmodified, I get a crash.

I believe the error is that the compiler is willing to compile this code. Note that it does notice the code's problem when -Wall is used.
>How-To-Repeat:
Compile the code and run it.
>Fix:
Manually ensure that each function has a return statement for every path, or compile with -Wall.

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-csrc; name="x.C"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="x.C"

I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGlvc3RyZWFtPgoK
dXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZlY3RvcjxzdHJpbmc+IGZvbygpCnsKfQoKaW50IG1haW4o
KQp7CiAgY291dCA8PCBmb28oKS5zaXplKCkgPDwgZW5kbDsKICByZXR1cm4gMDsKfQo=


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

end of thread, other threads:[~2003-03-12 21:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-12 21:36 c++/10048: Compiler doesn't catch failure to return a value - causes crashing code Christian Convey
  -- strict thread matches above, loose matches on Subject: below --
2003-03-12 21:28 bangerth
2003-03-12 20:36 cjc

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).