Subject: gcc 3.3.1 broke exceptions
To: None <tech-toolchain@netbsd.org>
From: Patrick Welche <prlw1@newn.cam.ac.uk>
List: tech-toolchain
Date: 10/03/2003 18:33:47
Is this already known?

quartz% cat throw.cc
#include <stdexcept>

using namespace std;

void func(void)
{
  throw runtime_error("in func()");
}
quartz% cat catch.cc
#include <iostream>
#include <stdexcept>

using namespace std;

void func(void);

int main()
{
  try {
    func();
    return 0;
  }
  catch(const runtime_error& e) {
    cerr<<"runtime error: "<<e.what()<<endl;
    return 1;
  }
}
quartz% g++ -shared -o libthrow.so throw.cc
quartz% g++ catch.cc -o prog -L. -Wl,-R. -lthrow
quartz% g++ -v
Using builtin specs.
gcc version 2.95.3 20010315 (release) (NetBSD nb4)
quartz% ./prog
runtime error: in func()


but with
% g++ --version
g++ (GCC) 3.3.1
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% ./prog
Abort trap (core dumped)


#0  0x481077a7 in kill () from /usr/lib/libc.so.12
#1  0x4817a4bb in abort () from /usr/lib/libc.so.12
#2  0x4805e2f5 in __frame_state_for () from ./libthrow.so
#3  0x4805e4e3 in _Unwind_RaiseException () from ./libthrow.so
#4  0x480bb198 in __cxa_throw () from /usr/lib/libstdc++.so.5
#5  0x4805d150 in func() () from ./libthrow.so
#6  0x08048b72 in main ()
#7  0x08048902 in ___start ()

(both NetBSD/i386, one from just before the gcc3 switch, the other from after)
Do I new flags?

Cheers,

Patrick