It appears that, in a special case here, the boolean typecast is not
being done properly/completely, and thus an array is being indexed out
of bounds. If I compile with rangechecking, I get a rangecheck error;
without, I get garbage and an EAccessError exception! (trash and crash)
uses math;
type
rounding_func = function (x : extended) : longint;
const
t_or_f : array [boolean] of string = ('false', 'true');
ceil_or_floor : array [boolean] of rounding_func = (@floor, @ceil);
var
b : boolean;
begin
b := boolean (6 and 4);
writeln (t_or_f [b]);
writeln (ceil_or_floor [b] (2.5));
end.
I was previously using boolean (6 and 4) as the array index directly,
but I thought the example was easier to read this way, and it still
crashes for me. Using fpc 2.2.4-3 and (mostly) debian 5.0.3 stable
This smells like a bug to me.
Cheers,
David.
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal