RangeChecking messes with absolute'd arrays.
Original Reporter info from Mantis: Solstice Projekt
-
Reporter name:
Original Reporter info from Mantis: Solstice Projekt
- Reporter name:
Description:
See Title. I have no better description.
The example shows it all.
Steps to reproduce:
{$R+}
program test_absolute;
Uses Windows, SysUtils;
Var
There : Pointer;
Here : Array of Byte absolute There;
q : dword;
Procedure RangeCheckError(_q : dword);
Var
_dest : Array of Byte absolute _q;
Begin
WriteLn(qword(@q));
WriteLn(qword(@_q));
WriteLn(qword(@_dest[0]));
End;
Begin
There := VirtualAlloc(nil,1024*1024,MEM_COMMIT or MEM_RESERVE,PAGE_READWRITE);
WriteLn(qword(There));
WriteLn(qword(@Here[0]));
End.
Output:
---------------------------------------------------------------------------------------- 97124352 An unhandled exception occurred at $00000001000066F7: EAccessViolation: Access violation $00000001000066F7 $0000000100001617 $0000000100001656 $000000010000C223 $000000010000CCD1 $00007FFA77337BD4 $00007FFA783CCE71 ----------------------------------------------------------------------------------------
.. but ONLY when RangeChecking is enabled. It works fine otherwise!
Note that using GetMem instead of VirtualAlloc ALWAYS works.
Output with RangeChecking commented out:
----------------
20971520
20971520
----------------
... as it should be.
I have found different issues with "absolute" when used with parameters in procedures/functions,
but one at a time, I guess.
What's not working here?
Thank you.
Mantis conversion info:
- Mantis ID: 35979
- Build: 2017/10/06
- Version: 3.0.4