compiler forgets to write the result into the array when optimisation -O3 is enabled
Original Reporter info from Mantis: CandyMan
-
Reporter name: Radek
Original Reporter info from Mantis: CandyMan
- Reporter name: Radek
Description:
// Compiled with option -O3 for Win32-I386
type
PWordArray = ^TWordArray;
TWordArray = array [0..1023]of Word;
WordRec = packed record
LoByte,HiByte:Byte
end;
var
Buffer:TWordArray;
OldMousePos:LongInt = 0;
ScreenBuffer:Pointer = @Buffer;
procedure Show(ScreenBuffer:Pointer);
begin
WordRec(PWordArray(ScreenBuffer)^[OldMousePos]).HiByte:=(not
WordRec(PWordArray(ScreenBuffer)^[OldMousePos]).HiByte)and $7F
// he forgets to write the result into the array
end;
begin
Buffer[0]:=$0000;
Show(ScreenBuffer);
WriteLn('Valid=',Buffer[0]=$7F00);
end.