Hello friends,
I would like to do something like:
type Conditional_Result (Exists : Boolean := False) is
record case Exists is
when True =>
Value : Natural;
when False => null;
end record;
procedure Do_Something(x : in Natural; rtn : out Conditional_Result)
is
begin
if x = 0 then
rtn := (Exists => False);
else
rtn := (Exists => True; Value => x + 1);
end if;
end;
procedure Foo is
rtn : Conditional_Result;
begin
Do_Something(0, rtn);
if rtn.Exists then
Put_Line("Yes!");
end if;
Do_Something(1, rtn);
if rtn.Exists then
Put_Line("Yes!");
end if;
end;
ALRM 2005 and Barnes seem to say the procedure Do_Something will know
that rtn in foo is unconstrained and allow both calls to succeed. In
GNAT 2007, the second call fails with a constraint error at the
assignment to rtn. Can you tell me what I'm missing?
Thanks!