From 7f94876fa87274c29ef10b38c783c95408054e97 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Mon, 26 Mar 2018 18:30:45 -0500 Subject: [PATCH] Fix mis-optimization of "expression && non-zero constant" operations with 32-bit type. The previous code may have been intended to convert this to a "!=0" test, which would have been valid if correctly implemented, but with the current code generator that actually yields worse code than the original version, so for now I just removed the optimization for this case. This problem could lead to crashes in code like the following (derived from a csmith-generated test case): #pragma optimize 1 int main(int argc, char *argv[]){ long l_57 = argc; return (4 ^ l_57) && 6; } --- DAG.pas | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/DAG.pas b/DAG.pas index c5e2121..39a6984 100644 --- a/DAG.pas +++ b/DAG.pas @@ -1569,9 +1569,7 @@ case op^.opcode of {check for optimizations of this node} end; {with} opv := op^.right; end; {if} - end {if} - else - op^.opcode := pc_neq; + end; {if} end; {if} end {if} else if op^.left^.opcode = pc_ldc then