I've looked at warnings I get in the Linux kernel with older compilers but not with more modern versions. Unsurprisingly, most are false positives, but I found three files that show a particular pattern that should be warned about: $ gcc-8.0.0 -Wall -c test.c -O2 # no warning $ gcc-8.0.0 -Wall -c test.c -O2 -fno-tree-vrp # warning test.c:12:9: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized] $ gcc-4.8 -Wall -c test2.c -O2 # warning test.c:12:2: warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized] The original warnings all show up with gcc-4.6 and earlier, but not with gcc-4.7+. The reduced test case also produces a warning with 4.7 and 4.8 but not with 4.9 through 8.0 unless -ftree-vrp is disabled: 8<--- int f(void); int mlx5_fpga_mem_read_i2c(int count) { int i, err; for (i = 0; i < count; i++) { err = f(); if (err) break; } return err; } ----->8 There are a lot of similar reports that are all marked duplicates of pr18501, but none of them have the particular loop/break pattern that I found in the three kernel files, so I'm opening another one to be sure. If the underlying problem is the same, please mark this one as duplicate as well.
We're just better in optimization as we figure that err is either uninitialized, zero or the f return value. And we now optimistically merge uninitialized with zero.
Dup. *** This bug has been marked as a duplicate of bug 18501 ***