On Mon, 27 Feb 2006, Adriaan van Os wrote:
[G5:gpc/testgpc/adriaan] adriaan% cat testsubrange.p
program testsubrange;
type int16 = integer attribute( size = 16); int32 = integer attribute( size = 32); point = record x,y: real end;
var i: int16;
procedure P( size: int32); begin writeln( 'size = ', size) end;
begin i:= 3658; P( i * SizeOf( point)); end.
[G5:gpc/testgpc/adriaan] adriaan% gp testsubrange.p
[G5:gpc/testgpc/adriaan] adriaan% ./testsubrange size = -7008
Any comments ? Regards,
Adriaan van Os
Simplifying your program I observe the same problem:
PROGRAM testsubrange; var i: ShortInt; {signed 16 bit integer} j: SizeType; {unsigned 32 bit word} point : record x,y: real end; {takes 16 bytes} begin i:= 3658; j:= 16; writeln ('result1 = ', i*j); {58528, OK} writeln ('result2 = ', i*SizeOf(point)); {-7008, wrong} end.
My suspicion is that for calculating the second expression the compiler uses wrong operand size (16? bit) instead of 32 (function SizeOf returns a value of SizeType). BTW: -7008+2^16 = 58528
Hope that may help.
Ernst-Ludwig