Am Mi., 2. Jan. 2019, 17:05 hat Benito van der Zander <ben...@benibela.de>
geschrieben:

> The non-initialization of 'Result' has bitten me more than once in Delphi.
>
>
> Me, too. Usually the solution was to add a call to SetLength.
>
> That makes the bullshit hints especially bad.
>

Even in Delphi situations can occur where a dynamic array Result variable
is non-Nil already upon entry and then SetLength will simply manipulate
that preexisting array instead of working on a new array. In most cases
that probably won't have a real effect as the array is either set to empty
anyway or all it's elements are initialized by the function. That doesn't
change the fact however that the behavior *is* there and can potentially
lead to hard to debug problems.

The only exception for the warning could possibly be SetLength(Result, 0)
as that is the equivalent of "Result := Nil" or "Result := []" as 3.2.0 now
supports.

Anything else can potentially be a bug lying in wait.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to