Wrong uninitialized warning in boolean expessions with -O3
Original Reporter info from Mantis: kluug.net @onpok
-
Reporter name: Ondrej Pokorny
Original Reporter info from Mantis: kluug.net @onpok
- Reporter name: Ondrej Pokorny
Description:
If a function has an out parameter and it appears in a boolean expression, FPC does not understand this variable as initialized.
Happens only for managed types and only in -O3 (and above).
Steps to reproduce:
program Project1;
{$mode objfpc}{$h+}
uses
SysUtils;
function TryParse(const A: string; out S: string): Boolean;
begin
S := A;
Result := True;
end;
var
S: string;
I: Longint;
begin
if TryParse('1', S) and (S='1') then // warning - bug
WriteLn('OK');
if TryStrToInt('1', I) and (I=1) then // no warning - correct
WriteLn('OK');
end.
Mantis conversion info:
- Mantis ID: 36036
- Version: 3.3.1