[fpc-pascal] array [boolean] and typecasting fail
David Emerson
dle3ab at angelbase.com
Sat Oct 24 00:55:30 CEST 2009
On Fri 23 Oct 2009, ik wrote:
> 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.
Well, pascal is a typed language, so while I do realize that the
information is stored as false=0 and true=1, and that's how the array
is indexed internally when I make such a declaration, I expect a pascal
compiler to treat the boolean type intelligently. (It usually does :)
> "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 [...]
I did cast it to boolean! That's why it smells like a bug.
> > var
> > b : boolean;
> >
> > begin
> > b := boolean (6 and 4);
> > writeln (t_or_f [b]);
Cheers,
~David.
More information about the fpc-pascal
mailing list