Date: Wed, 09 Apr 2008 09:39:09 -0700 From: Yuri <yuri@rawbw.com> To: freebsd-hackers@freebsd.org Subject: C++ exceptions are broken in FreeBSD with gcc-compiled code? Message-ID: <47FCF12D.3070902@rawbw.com>
next in thread | raw e-mail | index | archive | help
I am unable to make a C++ program to catch an exception using the the
system g++ compiler.
> cat exc.C
#include <iostream>
#include <string>
using namespace std;
int main() {
try {
throw string("String");
} catch (string s) {
cout << "Caught an exception \"" << s << "\"\n";
}
}
* Failed attempts with system compiler (using /lib/libgcc_s.so.1 and
/usr/lib/libstdc++.so.6):
> echo $LD_LIBRARY_PATH
> g++ -fexceptions -o exc exc.C
> exc
Exception raised: Memory allocation failure!
> g++ -pthread -fexceptions -o exc exc.C
> exc
Exception raised: Memory allocation failure!
* Succeeded attempt with gcc-4.3.0 and -pthread option (using
/usr/local/gcc-4.3.0/lib/libgcc_s.so.1 and
/usr/local/gcc-4.3.0/lib/libstdc):
> echo $LD_LIBRARY_PATH
/usr/local/gcc-4.3.0/lib
> /usr/local/gcc-4.3.0/bin/g++ -pthread -fexceptions -o exc exc.C
> exc
Caught an exception "String"
* Failed attempt with gcc-4.3.0 without -pthread option (using
/usr/local/gcc-4.3.0/lib/libgcc_s.so.1 and
/usr/local/gcc-4.3.0/lib/libstdc):
> echo $LD_LIBRARY_PATH
/usr/local/gcc-4.3.0/lib
> /usr/local/gcc-4.3.0/bin/g++ -fexceptions -o exc exc.C
> exc
Abort trap: 6
So exceptions *only* work with new gcc-4.3.0 and -pthread option.
Is this a known issue?
> g++ --version
g++ (GCC) 4.2.1 20070719 [FreeBSD]
> uname -a
FreeBSD xxx.xxx.xxx 7.0-STABLE FreeBSD 7.0-STABLE #5: Thu Feb 28
03:58:20 PST 2008 yuri@xxx.xxx.xxx:/usr/obj/usr/src/sys/GENERIC i386
Yuri
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47FCF12D.3070902>
