// Test piece from Sergei Poselenov Sep 26, 2008 in gcc-dev mailing list // "GCC 4.2.2 arm-linux-gnueabi: c++ exceptions handling?" // // arm-linux-gnueabi-g++ -o cond1 cond1.C // ./cond1 // // Should silently exit 0. Failure is greeted with the message: // terminate called after throwing an instance of 'int' // terminate called recursively // Aborted // caused by binutils 2.17.50.0.12, fixed in 2.17.90 and later. extern "C" void abort(void); #define CI(stmt) try { stmt; abort(); } catch (int) { } struct has_destructor { ~has_destructor() { } }; struct no_destructor { }; int PI(int& i) { return i++; } int main(int argc, char *argv[]) { (argc+1 ? has_destructor() : throw 0); CI((argc+1 ? throw 0 : has_destructor())); }