Fix optimizer bug where tests of long or floating-point constants can trash the stack.

This problem could lead to crashes in code like the following (derived from a csmith-generated test case):

#pragma optimize 1
int main (void)
{
    if (1L) ;
}
This commit is contained in:
Stephen Heumann 2018-03-26 21:54:01 -05:00
parent f2d15b8fc7
commit 21493271b9
1 changed files with 2 additions and 0 deletions

View File

@ -1327,6 +1327,7 @@ case op^.opcode of {check for optimizations of this node}
op^.right := nil;
end;
end; {case}
op^.optype := cgWord;
end {if}
else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin
if op^.right^.q = 1 then
@ -1755,6 +1756,7 @@ case op^.opcode of {check for optimizations of this node}
op^.right := nil;
end;
end; {case}
op^.optype := cgWord;
end {if}
else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin
if op^.right^.q = 0 then