https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85872
Bug ID: 85872 Summary: False positive for -Wmaybe-unitialized Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: jakub.leszczak at nokia dot com Target Milestone: --- Created attachment 44161 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44161&action=edit File contains informations about the bug and environent (uname, gcc --version, *.i files etc.) There is a false positive for maybe-unitialized when using -O1 (but not for -O0). Minimal case I got after stripping code: ``` int test1(int *t); int test(int *t, int e) { int i, f = 0; if (e != 0) { for(i = 0; t[i] != e; i++); } else { f = 1; } int j; if (test1(&j)) return 1; if (test1(&j)) return 1; if (test1(&j)) return 1; if (test1(&j)) return 1; if (test1(&j)) return 1; #if TEST if (test1(&j)) return 1; #endif if (!f) { return t[i]; } return 0; } ``` doesn't compile with `$ gcc -Wall -Werror -O1 -DTEST=1 -c bug.c`. But it compiles when either I turn off optimizations or set TEST=0. For some reason adding one additional `if (test1(&j)) return 1;` makes a difference. Tested on arch linux, ubuntu 16.04 and gcc.godbolt.org, on multiple gcc versions: 5.4.0, 7.3.1, 8.1.0, aarch64-linux-gnu-gcc6.4.1 and arm-linux-gnueabihf-gcc4.7.3.