From 97cca8471357d4c1817c9a1e32b27b67b981924c Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 29 Dec 2015 00:59:20 -0600 Subject: [PATCH] When pointer arithmetic is used to initialize a global or static variable to point before the beginning of a string constant, initialize it to the value indicated by the pointer arithmetic. Previously, such initializations would sometimes generate a garbage value pointing up to 65535 bytes beyond the start of the string constant. (This was due to a lack of sign-extension in the object code generation.) Computing a pointer to before the start of an object invokes undefined behavior, so the previous behavior wasn't technically wrong, but it was unintuitive and served no useful purpose. The new behavior should at least be easier to understand and debug. --- Native.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Native.pas b/Native.pas index 9b0ae4a..1e639f7 100644 --- a/Native.pas +++ b/Native.pas @@ -400,7 +400,7 @@ var LabelSearch(maxLabel, 2, 0, 0); if operand <> 0 then begin Out(129); - Out2(operand); Out2(0); + Out2(operand); if (operand < 0) then Out2(-1) else Out2(0); Out(1); end; {if} if (flags & shift16) <> 0 then begin