As reported here: https://bugs.llvm.org/show_bug.cgi?id=34973
"catch(...)" should catch EVERYTHING, even a rethrow. This
patch changes the order in which things are checked to ensure
that a '...' catch will get a rethrow.
Differential D39013
[CFG] Relax Wexceptions warning on rethrow erichkeane on Oct 17 2017, 11:09 AM. Authored by
Details As reported here: https://bugs.llvm.org/show_bug.cgi?id=34973 "catch(...)" should catch EVERYTHING, even a rethrow. This
Diff Detail
Event TimelineComment Actions Have a question on the behavior here, see inline.
Comment Actions I've convinced myself that a re-throw with a catch around it should not be diagnosed, otherwise there is no way to suppress the warning in this case. It ends up being a false-positive in many cases. Comment Actions Wouldn't a catch-all handler suppress the warning in that case? e.g., void f() noexcept { try { throw; // rethrows } catch (int) { // We hope this catches it, and if it always does, then this is a fp warning. } catch (...) { // However, without cross-TU analysis, we can't know that detail and it seems plausible that // the active exception object is something else, so the catch-all is not unreasonable and adds // extra safety. The diagnostic (even if a fp) requires the developer to think about this case. assert(false); } }
Comment Actions
Yep, you're right of course. I'll revert to my first patch and update this. I'd surmised that false-positives were worse than false-negatives, but since there is a trivial workaround, I'm ok with that. Thanks for the quick review!
|