[fpc-pascal] small bug with pass-by-reference on array elem

David Emerson dle3ab at angelbase.com
Sat Jun 28 23:55:55 CEST 2008


I would post this directly to the bugs database, but I've never received 
my confirmation email (I've tried a couple times now, perhaps my ISP 
greylisting is blocking it?)


- If a param is passed-by-reference to a function without being 
initialized first, a warning is issued by the compiler.

- If the function defines the param as "out" rather than "var" (mode 
objfpc) then (usually) no such warning is issued.

- If, however, the param passed happens to be an array element, then an 
errant warning is issued. See the example:


{$mode objfpc}

procedure assign_it (out x : longint);
   begin
      x := 7;
   end;

var
   a : array [0..1] of longint;
   b : longint;

begin
   assign_it (b);   // no warning
   assign_it (a[1]);   // errant warning issued
end.


~David.




More information about the fpc-pascal mailing list