This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

-fomit-frame-pointer breaks correct exception handling



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]

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]