看板 FB_hackers 關於我們 聯絡資訊
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 _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"