From 21493271b9c21548a00287d31129e200b1fa7986 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Mon, 26 Mar 2018 21:54:01 -0500 Subject: [PATCH] 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) ; } --- DAG.pas | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DAG.pas b/DAG.pas index daced54..e378463 100644 --- a/DAG.pas +++ b/DAG.pas @@ -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