Here is my program inspired by Barnes' Ada 95 2nd book page 158:
--bug1.ads
package bug1 is
I : Integer := 0;
A: array(1.. 10) of Integer := (others => 0);
procedure Silly(X: in out Integer);
end bug1;
--bug1.adb
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
package body bug1 is
procedure Silly(X: in out Integer) is
begin
I := I+1;
X := X+1;
end;
begin
A(5) := 1;
I := 5;
Silly(A(I));
Put(I, 0); --I should be 6 here
I := I+1;
Put(I, 0); --I should be 7 here
end bug1;
According to Barnes, and my understanding, 'I' should be 7 at the end of
the elaboration.
Calling "gnatmake -z bug1" I get
on Windows XP, with gcc version 4.1.3 20070403 for GNAT GPL 2007 (20070402)
I get I is 5 after the Silly call (wrong) and I is 6 at the end of the
elaboration
on Windows XP, with gcc version 3.4.1 (mingw special)
I get I is 6 after the Silly call (correct) and I is 6 (!!) at the end
of the elaboration
Both versions seem erroneous.
Can others confirm this bug?
Best Regards to the gcc community
chris