https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- Few middle-end warnings consider control flow -- most simply look at a single statement at a time and consider ranges of argument values (if any). Those that do consider control flow (e.g., -Wreturn-local-addr) only do so for PHI nodes that, for the most part, are the result of ?: expressions. We have work underway to improve the way GCC computes and exposes range information that we expect will help improve the accuracy in cases where there's more than a single range. I've also been thinking about changing some existing warnings to consider control flow to improve both their accuracy and efficacy, but this would only make a difference for PHI nodes. I haven't thought too much about using branch probabilities to decide whether to issue a maybe kind of a warning. Right now, a statement in the IL with a constant out-of-bounds argument triggers a definitive warning regardless of how likely the branch it's in is executed. It might be something to explore, though I would expect it to quickly turn most warnings in non-trivial code into the maybe kind. Using 'if (condition) __builtin_unreachable ();' shouldn't have an adverse effect on efficiency. Rather I'd expect it to improve codegen since it tells GCC that and any code that would otherwise be reachable after it can be eliminated. I would expect its effects to be comparable to __builtin_assume (condition).