------- Additional Comments From baldrick at free dot fr 2005-01-20 12:15
-------
Here is a simpler example:
with Ada.Text_IO; use Ada.Text_IO;
procedure T is
type Index_Type is range 0 .. 4; -- does not fail if lower bound is 1
type Unconstrained_Array_Type is array (Index_Type range <>) of Integer;
subtype Array_Type is Unconstrained_Array_Type (2..4);
Target : array (1 .. 1) of Array_Type;
procedure Check (Index : Index_Type; Value : Integer) is
begin
if Target (1) (Index) /= Value then
Put_Line ("Expected " & Integer'Image (Value) & ", found " &
Integer'Image (Target (1) (Index)));
end if;
end Check;
begin
Target := (1 => (1 => 20, 2 => 30, 3 => 40)); -- the assignment requires
sliding
Check (2, 20);
Check (3, 30);
Check (4, 40);
end;
> gnatmake -s -g t
...
> ./t
Expected 20, found 30
Expected 30, found 40
Expected 40, found 134596128
This seems to be a front-end problem. In the dump t.adb.t02.original the
assignment is:
A15b[1]{lb: 1 sz: 12}[1]{lb: 2 sz: 4} = 20;
A15b[1]{lb: 1 sz: 12}[2]{lb: 2 sz: 4} = 30;
A15b[1]{lb: 1 sz: 12}[3]{lb: 2 sz: 4} = 40;
For the first assignment, notice the lower bound of 2, but the assignment to
element 1. All the assignments are off by one index.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19409