[fpc-devel]bug in comparing of two pchars
Pavel V. Ozerski
pavel at insect.mail.iephb.ru
Mon Mar 19 11:42:04 CET 2001
>You cannot compare PChar strings directly using the "=" operator; use
>functions such as strcomp instead. PChar is just a pointer type, and "="
>will compare the address.
>"p='T'" is a special case: Here the compiler does an automatic pointer
>dereference, and as PChar is equivalent to ^Char, it's clear that this
>comparison will check the first character of p.
It's all could be true but:
1) Delphi supports this comparing;
2) Also FPC supports it if length of untyped string constant is more than 1-char. You could test it also
using my example: only ONE error will be found in source by compiler! If you remove second comparing,
this source will be successfully compiled. May be, this feature seems to be superfluous, but Borland-compatibility
is also an important thing.
Pavel V. Ozerski | Inst. of Evolutionary Physiology & Biochemistry,
office +7 (812)552-6870(291)| Russian Academy of Sciences,
FAX +7 (812)552-3012 | Thorez pr. 44, St.Petersburg, 194223, Russia
home +7 (812)528-5576 | E-mail: pavel at insect.mail.iephb.ru
| pavel at insect.ief.spb.su
More information about the fpc-devel