[fpc-devel]SizeOf() reports 0 for Var Paramaters. (1.1)

Jon Sawyer bq at badquanta.net
Sun Jul 27 18:19:12 CEST 2003


O_o Woah.. Weird.  Ok.. I thought it worked.. but mabey not.  1.0.6 seems to 
return 4 for SizeOf() a var param.  While 1.1 returns 0.

Progam Test1;

Procedure DoTest(var A);
Begin
	Writeln('SizeOf A = ', SizeOf(A) );
end;

var
	A : QWord;
Begin
	A := 2390;
 	Writeln('SizeOf A = ', SizeOf(A) ); 
	DoTest(A);
end.

On 1.0.6 it outputs:
SizeOf A = 8
SizeOf A = 4

On 1.1 it Outputs:
SizeOf A = 8
SizeOf A = 0


On Sunday 27 July 2003 10:25, Marco van de Voort wrote:
> > I'm not certain but I'm pretty sure that under 1.0.6 SizeOf() reported
> > the proper size for Var paramaters.  If not then I think a compiler
> > warning may be in order for code like this... because I just spent an
> > hour tracking down this problem. ;)  Is there any other way of
> > determining the original size of the var param?
>
> IIRC it returns correct data for _typed_ open arrays, not for "generic"
> open arrays.
>
> So for
>
> proceduer bla(var a: array of longint);
> // high() and sizeof() are possible
>
> and for
>
> procedure bla(var a);
> // none.
>
> I'm pretty certain it was the same for 1.0.6. This was already the
> case in BP/TP (e.g. see the blockwrite and blockread procedures that
> require the length to be explicitely passed)
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel





More information about the fpc-devel mailing list