Bug#749574: gnat-4.9: Gnatlink fails with CONSTRAINT_ERROR in gnatlink.adb
I have found the reason why upstream gnatlink appears to work where
Debian's gnatlink fails.
Consider this program:
with Ada.Text_IO;
procedure A is
type String_Access is access String;
G : constant String (3 .. 5) := "345";
H : constant String_Access := new String'(G);
begin
if G (1 .. 2) = "ab" then -- line 1
Ada.Text_IO.Put_Line ("True");
else
Ada.Text_IO.Put_Line ("False");
end if;
if H.all (1 .. 2) = "ab" then -- line 2
Ada.Text_IO.Put_Line ("True");
else
Ada.Text_IO.Put_Line ("False");
end if;
end A;
If you compile normally, GNAT correctly warns that Constraint_Error will
be raised at run time at line 1 since the bounds of G are static (3..5)
and different from the ones in the "if" statement; and this is exactly
what happens if you run the program.
If you compile with -gnatpg, you get no warning and the program runs and
prints:
False
False
Well, gnatlink.adb contains such a construct at line 2195. Upstream
compiles gnatlink.adb with -gnatpg and Debian compiles it without
-gnatpg, thereby forcing conformance with Ada semantics. This explains
the difference in behavior.
--
Ludovic Brenta.
Reply to: