https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64181
Mikhail Maltsev <miyuki at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Status|UNCONFIRMED |NEW Last reconfirmed| |2015-06-02 CC| |miyuki at gcc dot gnu.org Component|c++ |ipa Ever confirmed|0 |1 Known to fail| |5.1.0, 6.0 --- Comment #2 from Mikhail Maltsev <miyuki at gcc dot gnu.org> --- Happens if calls get inlined in some "special" way (in this testcase, invoke() is inlined into execute() and lambda is inlined into run(), i.e. we have 3 functions: throw_exception, run and main). $ cat test.cc template <typename F> struct Helper { F func; Helper(F f) : func(f) {} virtual void run() { func(); } }; struct Tester { template <typename F> void invoke(F f) { Helper<F> h(f); auto volatile ptr = &h; ptr->run(); } virtual void throw_exception() { throw 2; } void execute() { invoke([this]() noexcept { throw_exception(); }); } }; int main() { Tester t; try { t.execute(); } catch (int) { } } $ g++ -std=c++11 -O1 ./test.cc $ ./a.out terminate called after throwing an instance of 'int' Aborted $ g++ -std=c++11 -O3 ./test.cc $ ./a.out (no output)