[fpc-pascal]Re: "for" loop questions

Balogh, Karoly (Charlie/iNQ) charlie at scenergy.dfmk.hu
Sun Dec 8 10:44:45 CET 2002


Hi,

On 02.12.08., XHajT03 at mbox.vol.cz wrote:

>> But you should. :) I don't know the type of L.Count, but i suppose
>> it's unsigned. If L.Count is 0, and you try to count until L.Count-1,
>> it it simply underflows at the -1 operation. And i will count to $FF,
>> $FFFF or $FFFFFFF, or whatever, depending on the type of L.Count. 
> This isn't really correct either; this would only be true if you 
> assign the result of subtraction to an unsigned variable; the 
> calculation itself is done after conversion to a signed type.

Is this true in every compiler mode? :) I believe to you, but then i
have no idea why i got some crashes with some cases very similar to
this in my own sources... Since the loop doesn't get executed then.
I simply added the checks, to avoid this case, because i thought
it's trivial why it crashes... 

>> And this is why you get an exception.
> Not really, see above. The exception doesn't seem to come from 
> the quoted code fragment (unless you've used some other compiler 
> version and there's some bug in that particular version).

Whoops. ;) I got the point now. Anyway, i even didn't tested the
source, because i was sure that causes the problem what i said.

Bye,
-- 
Charlie/iNQ
.:%[ Cybernetic Hydraulic Android Responsible for ]%:. 
.:%[    Logical Infiltration and Exploration      ]%:.
.:%[         Member of TeamOS/2 Hungary           ]%:.
.:%[     Member of Hungarian Amiga User Group     ]%:.





More information about the fpc-pascal mailing list