c++/293: Re: -fomit-frame-pointer breaks correct exception handling

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Thu Jun 8 15:16:00 GMT 2000


>Number:         293
>Category:       c++
>Synopsis:       -fomit-frame-pointer breaks correct exception handling
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          analyzed
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 08 15:16:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Corey Kosak <kosak@cs.cmu.edu>
>Release:        2.95.2
>Organization:
>Environment:
>Description:
 Date: Thu, 08 Jun 2000 16:54:40 -0400
 Original-Message-ID: <17042.960497680@amphipolis.cmcl.cs.cmu.edu>


 This is either a bug in the implementation or a bug in the documentation.
 i.e. if the implementation of exceptions _requires_ the frame pointer, I would
 propose that the gcc documentation include a warning to that effect.


 $ g++ -v && cat b2.cc
 Reading specs from /usr/local/libexec/gcc-latest-snapshot/bin/../lib/gcc-lib/i686-pc-linux/2.96/specs
 gcc version 2.96 20000605 (experimental)
 #include <iostream.h>

 struct cow_t {
   cow_t()  { cout <<"created a cow\n"; }
   ~cow_t() { cout <<"destroyed a cow\n"; }
 };

 struct error_t { };

 void func2()
 {
   throw error_t();
 }

 void func1()
 {
   cow_t cow;
   func2();
 }

 int main()
 {
   try {
     func1();
   }
   catch(...) {
     cout <<"caught an exception\n";
   }
 }


 $ g++ b2.cc && a.out
 created a cow
 destroyed a cow
 caught an exception

 $ g++ -fomit-frame-pointer b2.cc && a.out
 created a cow
 caught an exception


 [note that the cow is not destroyed in the latter case]

>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-prs mailing list