[fpc-devel] fpc_pchar_length error
Alexandrov Alexandru
alexandru.alexandrov at gmail.com
Mon Dec 12 14:29:03 CET 2005
On 12/12/05, Michael Van Canneyt <michael at freepascal.org> wrote:
>
>
> On Mon, 12 Dec 2005, Jonas Maebe wrote:
>
> >
> > On 11 dec 2005, at 22:22, Alexandrov Alexandru wrote:
> >
> >>> It depends on the specs of "length" :-)
> >>
> >> What do you mean with specs?
> >
> > How it is defined to behave in the documentation (i.e., whether the
> > documentation says "if you call length with as argument a nil pointer, the
> > result is defined to be 0", or "the behaviour of length with as argument a
> > nil pointer is undefined", or simply doesn't mention it at all).
>
> Exactly.
>
> >> btw i forgot to mention, i tested on winxp.
> >> In Delphi the result is 0, and no error.
> >
> > Delphi obviously is a lot more tolerant to bad programming than we are... A
> > pchar which is nil is not an empty string, but an invalid pointer. It's like
> > assuming that a nil pointer to a longint is the same as a pointer to the
> > value 0 or so.
>
> I agree with this position.
> A Nil pointer is usually a sign of a bad or uninitialized value.
..but we speak here about the length of the string. IMO the length of
null string is the same as the length of an unitialised string.
Alex
More information about the fpc-devel
mailing list