Inlined function returns wrong value
Inlined function returns wrong value.
Lazarus 2.3.0 (rev main-2_3-2863-g1d9dfb7574) FPC 3.3.1 x86_64-linux-qt
Demo program:
program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads, SysUtils,
{$ENDIF}
Classes
{ you can add units after this };
{$R *.res}
var G, i: LongWord;
function GetValue(A: LongWord): LongWord; inline;
begin
Result:=G*A shr 32;
end;
begin
G:=123456789;
i:=GetValue(1);
writeln('i: ', i);
Sleep(250);
end.
Output is 123456789. Expected output is 0. (which is when you comment the inline; keyword)
It seems it does not depend on optimization level.