On 19 Jun 2009, at 06:45, Bruce Tulloch wrote:

type
   function F ( C : TArray ) : TArray;
   begin
      { does nothing }
   end

begin
   SetLength(B,4);
   for I := 0 to 3 do
      B[I] := I;

   A := Copy(B);
   A := F(B); { what is the correct answer here? }
end;

a question arises as to the value of A. Should it be nil or should it be
a copy of B?

Both are correct from a compiler implementation point-of-view, because the result of your function call is undefined.

Obviously F not assigning Result is a programming error, but
unfortunately it can be a common one in legacy code.

As Vincent indicated, we do not aim for implementing the same undefined behaviour as Delphi (we already have our hands full with implementing the defined behaviour ;)


Jonas
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to