[fpc-pascal]compiler bug?
    Peter Vreman 
    peter at freepascal.org
       
    Sun Jan  5 23:18:09 CET 2003
    
    
  
> Peter Vreman wrote:
>>
>> > The following program compiles but crashes with an integer range error
>> > when it gets to the comparison:
>> >
>> > {$R+}
>> > var
>> >   a : cardinal;
>> >   b : longint;
>> > begin
>> >   a := 0;
>> >   b := -1;
>> >   if a > b then writeln ('OK');
>> > end.
>> >
>> > Am I missing something, or is this a compiler bug?
>>
>> This is a bug. Added it as tb0447 to the testsuite.
>>
>> Workaround is to use int64(a) in the comparison
>
> OK, int64 works around that one....but what about this one, which
> crashes on the call to inc (I guess inc can't handle a 64 bit parameter):
>
> {$R+}
> var
>   a : ansistring;
>   b : cardinal;
> begin
>   a := 'hello';
>   b := -1;
>   inc (b, int64(length (a)));
> end.
the b:=-1 is not valid. The 1.1 compiler gives a correct error for it:
p.pp(7,8) Error: range check error while evaluating constants
    
    
More information about the fpc-pascal
mailing list