https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100394
--- Comment #4 from Michael Matz <matz at gcc dot gnu.org> --- That then still shows problems with the pure function and -O2, but with standard C++ this then works: struct S { int foo(int i) const { if (i) throw 42; return 0; } }; int __attribute__((noinline)) bar2() { S s; int a[2]; try { int res = s.foo (1); a[0] = res; } catch (...) { return 0; } return 1; } int main() { if (bar2 ()) __builtin_abort (); return 0; }