Fix bug where bitwise binary ops on 32-bit values will be miscalculated and trash the stack in certain cases.

The following program (derived from a csmith-generated test case) demonstrates the crash:

#pragma optimize 8+64
#include <stdio.h>
long g = 0;
int main (void) {
    long l = 0x10305070;
    printf("%08lx\n", l ^ (g = (1 , 0x12345678)));
}
This commit is contained in:
Stephen Heumann 2018-03-27 20:11:45 -05:00
parent c2b24f2854
commit 7605b7bbf2
1 changed files with 4 additions and 1 deletions

View File

@ -3895,7 +3895,10 @@ procedure GenTree {op: icptr};
lab1: integer; {label number}
begin {GenOp}
GenImplied(m_pla);
if gLong.where = A_X then
GenImplied(m_phx)
else
GenImplied(m_pla);
if gLong.where = constant then begin
GenNative(opi, immediate, long(gLong.lval).lsw, nil, 0);
GenImplied(m_pha);