-OoDEADSTORE takes on too much, chapter Ⅳ.
I just found that compiling my application with and without -OoDEADSTORE
and diffing -al
assembler outputs yields exclusively -OoDEADSTORE
bugs, maybe because I dislike to write the code that would be affected by -OoDEADSTORE
in the first place...
This code compiled with -O4 -OoDEADSTORE
drops chosen := -10
. Funny thing is that doing something at all in then
makes the bug disappear, not to speak of negating if
condition and moving break
into then
.
{$mode objfpc}
function ChooseMinus10: SizeInt;
var
chosen: SizeInt;
begin
chosen := -10;
repeat
if random(1) = 0 then else break;
exit(chosen);
until false;
result := -20;
end;
begin
writeln('Must be -10: ', ChooseMinus10);
end.
Possible output:
Must be -10: 857404