https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55035
Mikhail Maltsev <miyuki at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2015-04-09 00:00:00 |2015-5-20 CC| |miyuki at gcc dot gnu.org Known to fail| |6.0 --- Comment #5 from Mikhail Maltsev <miyuki at gcc dot gnu.org> --- Reduced testcase: $ cat ./warn2.cc int arr[1]; int N; void bar(); void foo() { int temp[2]; for (int i = 0; i < N; i++) temp[i] = arr[i]; bar(); for (int i = 0; i < N; i++) arr[i] = temp[i]; } $ /opt/gcc-6.0.0/bin/g++ -c -Wall -O2 -fdump-tree-all ./warn2.cc ./warn2.cc: In function 'void foo()': ./warn2.cc:13:21: warning: 'temp[0]' may be used uninitialized in this function [-Wmaybe-uninitialized] arr[i] = temp[i]; $ /opt/gcc-6.0.0/bin/g++ -c -Wall -O2 -fno-tree-sra ./warn2.cc (no warning) GCC performs scalar replacement of "temp" and unrolls both loops. N is global and can be modified by bar(). The final GIMPLE looks like this: $ cat ./warn2.cc.190t.optimized void foo() () { int temp$0; int N.0_18; int N.0_24; <bb 2>: N.0_24 = N; if (N.0_24 <= 0) goto <bb 4>; else goto <bb 3>; <bb 3>: temp$0_25 = arr[0]; <bb 4>: # temp$0_26 = PHI <temp$0_25(3), temp$0_27(D)(2)> bar (); N.0_18 = N; if (N.0_18 <= 0) goto <bb 6>; else goto <bb 5>; <bb 5>: arr[0] = temp$0_26; <bb 6>: return; } Here temp$0_27(D)(2) is the "uninitialized" case. In the original testcase recog_data.n_dups is considered escaped and orig_dup[0] is treated the same way as temp[0].