[Bug ada/61466] New: Array index check optimized away
simon at pushface dot org
gcc-bugzilla@gcc.gnu.org
Tue Jun 10 20:11:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61466
Bug ID: 61466
Summary: Array index check optimized away
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: simon at pushface dot org
Created attachment 32916
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32916&action=edit
Source code (package spec/body, main procedure)
In the attached code, the index check in procedure Violate on the “Output: out
Arr” parameter is present with -O0 but is omitted with higher levels. This is
clearly visible with -gnatG:
-O0:
L_1 : for j in input'first .. input'last loop
B_2 : declare
[constraint_error when
not (integer(j) in modifier'first .. modifier'last)
"index check failed"]
product : constant integer := modifier (j);
begin
[constraint_error when
not (integer(j) in output'first .. output'last)
"index check failed"]
output (j) := product / 2;
end B_2;
end loop L_1;
-O1:
L_1 : for j in input'first .. input'last loop
B_2 : declare
[constraint_error when
not (integer(j) in modifier'first .. modifier'last)
"index check failed"]
product : constant integer := modifier (j);
begin
output (j) := product / 2;
end B_2;
end loop L_1;
The bug is present at least in GCC 4.6 on Debian and GCC 4.7 .. 4.9 on Mac OS
X, also in GNAT GPL 2012 .. 2014.
More information about the Gcc-bugs
mailing list