int main() { int i, j; for( j=0; j<10; j++ ) { printf( "%d\n", i ); for( i=0; i<10;i++ ); } return 0; } compiling above code with -Wuninitialized is supposed to issue warning which is not happening.
It does if you enable -O1 (but not with -O0 or -O2+)
Confirmed with the top of trunk (7.0).
It is a dup of all the uninit PRs caused by CCP turning PHI<undef, X> into X (X=10 here).
I ran into the same bug with this code: double weight() { double sum; int i; for (i=0; i<10; i++) { sum++; } return sum; } With -Wuninitialized or -Wmaybe-uninitialized, no warning is generated with -O0. The warning is generated with -O1, -O2, -O3. Other compilers (such as clang) generate the warning correctly. Confirmed with gcc 8.2.0.
Original report is PR18501. Comment #4 is PR54554. *** This bug has been marked as a duplicate of bug 18501 ***