Absolute keyword with Result variable
Summary
Assignment does not happen when using variable with absolute to the result address.
System Information
-
Operating system:
Windows 64 bit and Linux 64 bit
-
Processor architecture:
AMD64 and Intel 64-bit processor
-
Compiler version:
3.2.2
-
Device:
Computer
Code to reproduce
click to reveal code
program Test;
{$mode objfpc}
function F0(const value: UInt64): Double; inline;
var r: UInt64 absolute result;
begin
r := value;
end;
function F1(const value: UInt64): Double; inline;
var r: UInt64 absolute result;
begin
PUInt64(@result)^ := 0;
r := value;
end;
var d: Double;
begin
d := F0(1); Write(PUInt64(@d)^, #10);//incorrect - must be 1 and not 0
d := F1(1); Write(PUInt64(@d)^, #10);//correct
end.
Edited by Bufo Viridis