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.
This commit is contained in:
Stephen Heumann 2015-12-29 00:59:20 -06:00
parent d65cc99d9a
commit 97cca84713

View File

@ -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