http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55339
--- Comment #1 from anton.katilin at gmail dot com 2012-11-15 11:28:32 UTC --- Compile with: ------------------------------------- export PATH=/opt/gcc-4.7.2/bin:$PATH g++ -m32 -fPIC -O2 *.cpp -o test-O2.bin g++ -m32 -fPIC -O1 *.cpp -o test-O1.bin Please find the source code of the test below. ------------------------------------- Test.cpp ------------------------------------- #include <stdio.h> #include "Foo.h" int main() { try { printf("entering...\n"); fflush(stdout); YS(-1); // will throw exception printf("must never reach\n"); } catch (int) { printf("exception caught, as expected\n"); } printf("OK\n"); return 0; } ------------------------------------- Foo.h ------------------------------------- #pragma once void foo(); void checkPositive(int); class YS { public: YS(int capacity) { checkPositive(capacity); } ~YS() { foo(); } }; void throwException(const YS&); ------------------------------------- Foo.cpp ------------------------------------- #include "Foo.h" void foo() { } void checkPositive(int v) { if (v <= 0) { throwException(10); } } void throwException(const YS&) { throw int(1); }