[fpc-pascal]compiler bug?

Mark Emerson mark at angelbase.com
Sun Jan 5 22:01:20 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.




More information about the fpc-pascal mailing list