procedure test_a(ok : out Boolean) is
begin
if false then
ok := true;
end if;
end test_a;
I get the following output (using GNAT Community Edition):
ok_a = FALSE
ok_b = TRUE
As far as I understand, this is correct.
However, I think I remember that (some) older versions of the GNAT compiler gave a different result. Could others try? And does my program example reveal an unnecessary gotcha?
reinert
Hello,
Assume the following program:
with Text_Io; use Text_Io;
procedure test2 is
procedure test_a(ok : out Boolean) is
begin
if false then
ok := true;
end if;
end test_a;
procedure test_b(ok : in out Boolean) is
begin
if false then
ok := true;
end if;
end test_b;
ok_a,ok_b : Boolean := true;
begin
test_a(ok_a);
test_b(ok_b);
Put_Line("ok_a = " & ok_a'Image);
Put_Line("ok_b = " & ok_b'Image);
end test2;
I get the following output (using GNAT Community Edition):
ok_a = FALSE
ok_b = TRUE
As far as I understand, this is correct.
However, I think I remember that (some) older versions of the GNAT
compiler gave a different result.
And does my program example reveal an unnecessary gotcha?
On 13/11/21 18:46, reinert wrote:
I'd expect GNAT to issue a warning. Probably you need to add a flag to GNAT to enable that warning. Perhaps try adding '-gnatwa'.
procedure test_a(ok : out Boolean) is
begin
if false then
ok := true;
end if;
end test_a;
However, I think I remember that (some) older versions of the GNAT compiler gave a different result. Could others try? And does my program example reveal an unnecessary gotcha?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 353 |
Nodes: | 16 (2 / 14) |
Uptime: | 85:25:21 |
Calls: | 7,639 |
Files: | 12,803 |
Messages: | 5,694,299 |