On Sat, May 23, 2026 at 12:22 PM Matthias Kretz via Gcc <[email protected]> wrote: > > Jakub Jelinek via Gcc [Saturday, 23 May 2026, 11:53:43 CEST]: > > it is no longer VARYING range and the > > middle-end warning code thinks that in that case all other values need to be > > somehow possible and warns. > > For real? The warning emits "if any_of index_range is out-of-bounds"? Why then > not simply change it to "if all_of index_range is out-of-bounds"? The any_of > condition is a -Wmaybe-array-bounds situation.
That's how -Warray-bounds works, it warns only if all possible values (according to range) are not valid. The false positives we see there are exclusively in unreachable code we were not able to prove unreachable. -Wuninitialized warns when there is an uninitialized use on _any_ path we can _not_ prove to be unreachable (at least we try to prove and do not only rely on optimization to remove CFG paths). I think the other late diagnostics do neither, or rather I don't think there's an "designed" way to decide when to diagnose and when not. One issue with "reachable" is that this is all conditional on a function being entered at all (which we basically assume when deciding between may and must). So how a diagnostic is framed to the user can depend on inlining (inlining a function into conditional context turns a must into a may diagnostic). Overall I think we should spend time on improving -Wstringop-overflow and friends while they are still in -Wall. If we remove them from there there's going to be zero interest in doing that and I'd opt for killing them (their implementation) outright instead. The last times I looked at improving I tried to move them earlier (closer to where we now emit array bound diagnostics), but got scared by massive testsuite fallout. There are many ideas floating around for improving late diagnostics, but there's little work actually being done. Qings work on -fdiagnostics-show-path is great, but it can only be a first step. And yes, the main problem I see is the way we present these diagnostics to the user. Richard. > > - Matthias > > -- > ────────────────────────────────────────────────────────────────────────── > Dr. Matthias Kretz https://mattkretz.github.io > GSI Helmholtz Center for Heavy Ion Research https://gsi.de > std::simd > ──────────────────────────────────────────────────────────────────────────
