IMHO that's not on the same level as the original problems. You will get the
same result on any language that has the concept of `var` parameters and you
are working with a pointer type. The result is as expected. The problem is a
side effect in code flow. Here the same program in pascal.
program Hello;
{$mode Delphi}
{$ASSERTIONS ON}
type
TTest = record
flag: Boolean;
end;
PTest = ^TTest;
var test: PTest;
function newTest(): PTest;
begin
new(Result);
Result^.flag := false;
end;
procedure setFlag(var flag: Boolean);
begin
test:= newTest();
flag := true;
end;
begin
writeln ('Hello World');
test:= newTest();
setFlag(test^.flag);
assert(test^.flag, 'how could this happen?');
end.
Run