[fpc-pascal] type conversions

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Mon Dec 9 13:04:31 CET 2002


On Mon, 9 Dec 2002, Jonas Maebe wrote:

>
> On maandag, dec 9, 2002, at 12:06 Europe/Brussels,
> memsom at interalpha.co.uk wrote:
>
> >> No, a type conversion between ordinal types does not change one bit
> >> pattern into another. -1 is a bit pattern that only contains 1-bits,
> >> so
> >> when you convert that to an unsigned type, it still contains only
> >> 1-bits and as such becomes the highest value that that unsigned type
> >> can represent (65535 in case of an unsigned 16 variable).
> >
> > Whatever the truth, how else does the 'list index out of bounds (0)'
> > happen?
>
> TList.count returns -1, this is converted to a 16 bit unsigned value =
> 65535 -> the loop is run from 0 to 65535 (and crashes in the first
> iteration).

How can TList.count return a -1 ? Normally, this cannot happen.

Michael.





More information about the fpc-pascal mailing list