On Wed, 09 Apr 2008 09:39:09 -0700 Yuri <[EMAIL PROTECTED]> wrote: > I am unable to make a C++ program to catch an exception using the the > system g++ compiler.
% c++ -o exc exc.c % ./exc Caught an exception "String" % c++ -O2 -pthread -o exc exc.c % ./exc Caught an exception "String" % c++42 -O2 -pthread -o exc exc.c % ./exc Caught an exception "String" % c++42 -O2 -o exc exc.c % ./exc Caught an exception "String" % 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"; } return 0; } % uname -a FreeBSD kan.dnsalias.net 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sun Apr 6 14:22:23 EDT 2008 ... Same on RELENG_6 (do not have 7.0 around, but 8.0 and 7.0 are identical compiler-wise. Same on 8.0/amd64. BTW, do you have . in your PATH? > g++ -fexceptions -o exc exc.C > exc <==== should it be ./exc ? Exception raised: Memory allocation failure! ^^^^^^^^^^^ Not in your sample code. -- Alexander Kabaev
signature.asc
Description: PGP signature