See following code snippet; when the MY_THROW macro is changed to do { throw ::my_error( MeSSaGe ); } while( 1 )
then I get the expected result, i.e. invocation of the executable prints "error foo" and returns 1 to the shell... This is on an i7 iMac with Mac OS X 10.6.2 with 64bit Kernel and current GCC 4.4.3 from MacPorts. co...@tigger:/tmp> cat debug.cc #include <sstream> #include <iostream> #include <stdexcept> struct my_error : public std::runtime_error { explicit my_error( const std::string & message ) : std::runtime_error( message ) { } }; #define MY_THROW( MeSSaGe ) \ do { std::ostringstream oss; oss << MeSSaGe; throw ::my_error( oss.str() ); } while( 1 ) template< typename T > bool throwing( const T ) { MY_THROW( "foo" ); } int main() { try { throwing( 42.0 ); } catch ( const ::my_error & e ) { std::cerr << "error " << e.what() << "\n"; return 1; } return 0; } co...@tigger:/tmp> g++-mp-4.4 -Iinclude -std=c++0x -pedantic -Wall -Wextra -O3 -m64 -march=native debug.cc -o debug co...@tigger:/tmp> ./debug Abort trap co...@tigger:/tmp> g++-mp-4.4 --version g++-mp-4.4 (GCC) 4.4.3 Copyright (C) 2010 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. co...@tigger:/tmp> g++-mp-4.4 -v Using built-in specs. Target: x86_64-apple-darwin10 Configured with: ../gcc-4.4.3/configure --prefix=/opt/local --build=x86_64-apple-darwin10 --enable-languages=c,c++,objc,obj-c++,java,fortran --libdir=/opt/local/lib/gcc44 --includedir=/opt/local/include/gcc44 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.4 --with-gxx-include-dir=/opt/local/include/gcc44/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --enable-stage1-checking Thread model: posix gcc version 4.4.3 (GCC) co...@tigger:/tmp> -- Summary: exception ignores catch-clause when std::ostringstream helps in throwing Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc at cohi dot at GCC host triplet: 86_64-apple-darwin10 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43493