This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/82286] Wrong array subscript is above array bounds
- From: "hermantenbrugge at home dot nl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 26 Sep 2017 16:38:59 +0000
- Subject: [Bug middle-end/82286] Wrong array subscript is above array bounds
- Auto-submitted: auto-generated
- References: <bug-82286-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82286
--- Comment #4 from Herman ten Brugge <hermantenbrugge at home dot nl> ---
Created attachment 42238
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42238&action=edit
modified test case
I modified the testcase a little bit and did some debugging.
The code outputs a failure if compiled with:
gcc -O3 -Wall -c tst.c -DERROR -fdump-tree-cunrolli-details
tst.c: In function 'mtrx_decompose_matrix':
tst.c:34:17: warning: array subscript is above array bounds [-Warray-bounds]
sum += tmp.data[row][sub];
The code is ok of compiled with:
gcc -O3 -Wall -c tst.c -DERROR -fdump-tree-cunrolli-details
-fno-aggressive-loop-optimizations
or:
gcc -O3 -Wall -c tst.c -fdump-tree-cunrolli-details
The dumpfile that are created are in case of error containing or if
-fno-aggressive-loop-optimizations is given:
...
Analyzing # of iterations of loop 3
exit condition [0, + , 1](no_overflow) < row_8
bounds on difference of bases: 0 ... 4294967294
result:
# of iterations row_8, bounded by 4294967294
...
The dumpfile looks correct in the case the sqrtf function is not used:
...
Analyzing # of iterations of loop 3
exit condition [0, + , 1](no_overflow) < row_5
bounds on difference of bases: 0 ... 5
result:
# of iterations row_5, bounded by 5
...
Something must go wrong when aggressive-loop-optimizations is enabled.