Consider the following two functions: void foo() { int *as[2]; *(as[0])=1; } void bar() { int i = 0; int *as[2]; for(i=0;i<1;i++) { *(as[i])=i; } } When compiling these with -Wall, we get warnings about the uninitialized use of as in the first function, but not in the second one. GodBolt: https://godbolt.org/z/Ta9fWYWs6 Inspired by this StackOverflow question: https://stackoverflow.com/q/69764896/1593077
The foo form is handled by the early uninit pass but the bar form is optimized away as dead before we get to do a late warning.
(In reply to Richard Biener from comment #1) > The foo form is handled by the early uninit pass Since _none_ of `as` is initialized, one could argue that an early uninit pass could catch that as well.
The early uninit pass deliberately defers the conditional cases to the late pass to avoid false positives. It only handles straightforward unconditionally uninitialized reads. It could probably do better.