<div dir="ltr">The use of 'array[boolean]' does not mean that the array is true or false, but rather '0..1'. You indicate a range, not a boolean behavior. <br>"6 and 4" gives 4, and 4 is above the range of "1" (the highest cell of the array you declared). If you would have cast it to boolean, or provide a better usage, for example:<br>
<br>6 and 4 = 4<br><br>Then it would have worked as expected.<br><br>Ido<br><br clear="all"><a href="http://ik.homelinux.org/">http://ik.homelinux.org/</a><br>
<br><br><div class="gmail_quote">On Fri, Oct 23, 2009 at 3:00 AM, David Emerson <span dir="ltr"><<a href="mailto:dle3ab@angelbase.com">dle3ab@angelbase.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It appears that, in a special case here, the boolean typecast is not<br>
being done properly/completely, and thus an array is being indexed out<br>
of bounds. If I compile with rangechecking, I get a rangecheck error;<br>
without, I get garbage and an EAccessError exception! (trash and crash)<br>
<br>
uses math;<br>
<br>
type<br>
rounding_func = function (x : extended) : longint;<br>
<br>
const<br>
t_or_f : array [boolean] of string = ('false', 'true');<br>
ceil_or_floor : array [boolean] of rounding_func = (@floor, @ceil);<br>
<br>
var<br>
b : boolean;<br>
<br>
begin<br>
b := boolean (6 and 4);<br>
writeln (t_or_f [b]);<br>
writeln (ceil_or_floor [b] (2.5));<br>
end.<br>
<br>
I was previously using boolean (6 and 4) as the array index directly,<br>
but I thought the example was easier to read this way, and it still<br>
crashes for me. Using fpc 2.2.4-3 and (mostly) debian 5.0.3 stable<br>
<br>
This smells like a bug to me.<br>
<br>
Cheers,<br>
David.<br>
<br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</blockquote></div><br></div>