Consider this:
#include <stdexcept>
template <class T>
void F(T &&t) {
try {
t();
} catch(...) {}
}
int main() {
F([]() noexcept {}); // Call 1
F([]{}); // Call 2
F([]{ throw std::exception{}; });// Call 3
}
I found on clang++-6.0 with flags -std=c++17, regardless of the optimization flags I gave, there is always no __gxx_personality and any exception handling code for Call 1.
Can such optimization be relied on when using a different compiler? I only consider C++11 and above.
Aucun commentaire:
Enregistrer un commentaire