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 Authored by erichkeane on Oct 17 2017, 11:09 AM.
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!
| ||||||||||||||||||||||||
The other potential fix here is to simply change this line here to "return true;". This would result the warning being suppressed on 'rethrow' if there is any catch statements.
I wonder what the opinion of the reviewers is on this one.