On Wednesday 29 of February 2012 13:54:40 ik wrote:
> On Wed, Feb 29, 2012 at 14:44, LacaK <la...@zoznam.sk> wrote:
> > Hi *,
> > I found small incompatibility between Delphi and FPC.
> > 
> > This code:
> > var a,b: array of byte;
> > begin
> > 适适 setlength(a,2);
> > 适适 b:=copy(a,2,1); //<--HERE "Range check error" in FPC, Delphi returns
> > empty array
> > end;
> > 
> > Delphi documentation says:
> > "If Index is larger than the length of S, Copy returns an empty string or
> > array."
> > http://docwiki.embarcadero.com/VCL/en/System.Copy
> > 
> > Can it be fixed also in FPC?
> 
> I think it's a Delphi bug to act like that. You must provide a length
> that is not bigger in size. It's up to you the developer.
> Otherwise you might have more then one type of buffer overflows in your
> code !
> 
> The way Delphi solved it, is by taking the responsibility from the
> developer, and made the code a bit slower.
> And as I said, I don't think it's a good idea

+1 ... @lacak, better fix your code. I don't like to be delphi compatibile 
with such things.

zeljko
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to