When the first use of an uninitialized variable is inside a loop, no warning is generated when -Wuninitialized is turned on. int main(void) { int len, i; for(i = 0; i < 5; i++) { printf("%d\n", len); // no warning! len = 10; } return 0; }
Same behavior on 4.4.3 & 4.4.1 (same host, target & build) Forgot to mention: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)
It's just optimized to always print 10 and the maybe-uninitialized warning code runs too late. A dup of some other PR.
(In reply to comment #2) Richard, thanks for the confirmation. This is a great feature that we've come to rely on over the years for catching rookie errors. This might not appear in comments very often, but I appreciate the hard work you and the rest of the gcc folks put in.
CCP is responsible for this. *** This bug has been marked as a duplicate of 18501 ***