I believe this is related to Bug #43493 I cannot catch exceptions if a variable (non-static) is use for the message...
Using the following program: #include <cstdlib> #include <iostream> #include <sstream> #include <stdexcept> #include <string> using namespace std; void generateException(int whichException); int main(int argc, char ** argv) { for (int i=1; ; i++) { // Loop forever try { cout << i; generateException(i); } catch (runtime_error rex) { cout << " Catching: runtime_error - " << rex.what() << endl; } catch (...) { cout << " ERROR: Nobody caught this!" << endl; } } return 0; } void generateException(int whichException) { switch (whichException) { case 1: cout << " Throwing runtime_error (1)" << endl; throw runtime_error( "a comment" ); break; case 2: cout << " Throwing runtime_error (2)" << endl; { static string msg( "a comment" ); throw runtime_error( msg ); } break; case 3: cout << " Throwing runtime_error (3)" << endl; { string msg( "a comment" ); throw runtime_error( msg ); } break; case 4: cout << " Throwing runtime_error (4)" << endl; { std::ostringstream msg ; msg << "a comment" ; throw runtime_error( msg.str() ); } break; default: cout << " Throwing up" << endl; exit(0); } return; } When I build with apple's g++ (4.2.1) or intel 11.1 icpc C++ compilers I get the following expected output: 1 Throwing runtime_error (1) Catching: runtime_error - a comment 2 Throwing runtime_error (2) Catching: runtime_error - a comment 3 Throwing runtime_error (3) Catching: runtime_error - a comment 4 Throwing runtime_error (4) Catching: runtime_error - a comment 5 Throwing up However, when I compile with gcc 4.3 or 4.4 installed with macports 1.9.1 I get: 1 Throwing runtime_error (1) Catching: runtime_error - a comment 2 Throwing runtime_error (2) Catching: runtime_error - a comment 3 Throwing runtime_error (3) Abort trap I also tried building gcc44 with the --without-system-libunwind configure flag and also got the same behavior. My system configuration is: MacPro 2x2.93GHz quad-core xeon MacOSX 10.6.4 Xcode 3.2.3 MacPorts 1.9.1 -- Summary: exception ignores catch-clause when using a variable for the message Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mwglass at sandia dot gov GCC build triplet: 86_64-apple-darwin10 GCC host triplet: 86_64-apple-darwin10 GCC target triplet: 86_64-apple-darwin10 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44954