Consider the following code:
struct T {
void f() noexcept { /* an arbitrary long piece of code */ }
};
void some_function() {
T t{};
try { t.f(); }
catch(...) {
std::cout << "Something is Wrong!!"; // An unreachable line of code
}
}
Is there any level of optimization in Clang and GCC that removes the whole try/catch
, and simply calls t.f()
instead? Is there any specific switch for enabling/disabling this optimization?