[fpc-devel] Comparing arrays of char

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Nov 2 14:03:50 CET 2009


Carsten Bager wrote on Mon, 02 Nov 2009:

> As far as I can see, the problem is the compiler does not differ between an
> array of char and a null terminated string.
> As a result of this, if the first byte/char are 0 in both arrays the compiler
> stops checking and says that there are equal.

When I implemented the current behaviour, I compared it either Turbo  
Pascal or Kylix 3 (which is Delphi 6.5), I'm not sure which one  
anymore. There,
a) if the array is zero-based (i.e., lower bound is 0), then the array  
of char is treated as a null-terminated string
b) if the array is non-zero-based, then the array of char is always  
checked completely

That should also be the current behaviour for FPC. So if you want to  
always use the full array, change your lower array bounds.


Jonas

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




More information about the fpc-devel mailing list