Why am I getting a different level (hint/warning) of the same compiler message in similar code, only differing in return type?

The following example:

program Project1;

uses SysUtils;

function Test1: String;
begin
  SetLength(Result, 0);
end;

function Test2: TBytes;
begin
  SetLength(Result, 0);
end;

begin
  Test1;
  Test2;
end.

compiles with messages:

Free Pascal Compiler version 3.3.1-11052-g621f3b8387-dirty [2022/05/19] for i386
Copyright (c) 1993-2022 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling project1.lpr
project1.lpr(7,19) Hint: Function result variable of a managed type does not seem to be initialized project1.lpr(12,19) Warning: Function result variable of a managed type does not seem to be initialized


Regards, MichaƂ.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to