[fpc-pascal] reference-counted function results not initialized to nil

Karoly Balogh (Charlie/SGR) charlie at scenergy.dfmk.hu
Sun Jun 26 20:36:20 CEST 2016


Hi,

On Sun, 26 Jun 2016, Jürgen Hestermann wrote:

> Am 2016-06-26 um 14:27 schrieb Karoly Balogh (Charlie/SGR):
> > There's no exception. At least not specifically for Result. It is simply
> > variable passed by reference from the caller side, therefore it's not
> > initialized inside the function.
>
> You mean when I have the following:
>
> --------------------------
> function X : ansistring;
> begin
> end;
>
> var S : ansistring;
>
> S := X;
> --------------------------
>
> Then S is a dangling pointer to nowhere?

No. In this case, S was initialized (to nil), because it's a global var.
This just won't be changed by the X function call. If you had S:='test';
Before S:=X; then it would still contain 'test' after it.

Charlie


More information about the fpc-pascal mailing list