Confirmed. Thanks for adding this meta-bug ... General note: most of these bugs are symptoms for missed VRP opportunities (though sometimes very hard to unleash).
A few more bugs should be added to this tracker: (It seems I don't have permission to do that?) bug 59124 bug 63441 bug 63477 bug 80907 bug 82286 Adding my own testcase here: extern int array[3]; void foo(int n) { for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) if (array[i] == array[j]) array[j] = 0; } gcc -Wall -O3 test.c triggers bogus warning(s) with any version of gcc >= 4.8
How essential is the "when inlining or unrolling" portion of the title for this bug? i.e., can it be used as a meta-bug for all -Warray-bounds issues? If not, how to tell if any given -Warray-bounds bug is related to inlining/unrolling or not?
On Tue, 17 Oct 2017, egallager at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456 > > Eric Gallager <egallager at gcc dot gnu.org> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |egallager at gcc dot gnu.org > > --- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> --- How > essential is the "when inlining or unrolling" portion of the title for > this bug? i.e., can it be used as a meta-bug for all -Warray-bounds > issues? If not, how to tell if any given -Warray-bounds bug is related > to inlining/unrolling or not? It's hard to tell. Unless we have another meta-bug just re-use this one.
Slightly smaller testcase, similar to bug 80907. extern int M[16]; void foo(int n) { for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) M[i+j] = 0; } $ gcc-7 -O3 -Wall -S testcase4.c testcase4.c: In function 'foo': testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds] M[i+j] = 0; ~^~~~~ testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds] testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds] testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds] testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds] testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds] testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds] testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds] Same result with trunk. Using -fopt-info adds: testcase4.c:5:3: note: loop turned into non-loop; it never loops. testcase4.c:5:3: note: loop with 17 iterations completely unrolled
(In reply to rguenther@suse.de from comment #4) > > It's hard to tell. Unless we have another meta-bug just re-use this one. I couldn't find another one that looked relevant so I'll re-use this one.
Now that this bug has become a tracker for both false positives and false negatives the inlining/unrolling part is not relevant anymore so adjusting the Summary.