[fpc-pascal] type conversions

Jonas Maebe jonas at zeus.rug.ac.be
Mon Dec 9 12:34:47 CET 2002

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 


More information about the fpc-pascal mailing list