mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-03-15 18:29:49 +00:00
Fix bug where ++/-- operations would use the wrong location for local variables that don't fit in the direct page.
The code would trash other data on the stack, which could corrupt other variables and in some cases lead to crashes. The following program (derived from a csmith-generated test case) shows the problem: #pragma optimize -1 int main(void) { char arr[256] = {0}; char l_565[3][2] = {{3,4}, {5,6}, {7,8}}; l_565[0][0]++; return l_565[0][0]; }
This commit is contained in:
parent
7605b7bbf2
commit
37cf771eee
8
Gen.pas
8
Gen.pas
@ -1893,13 +1893,13 @@ case op^.optype of
|
||||
else begin
|
||||
GenNative(m_ldx_imm, immediate, gLong.disp, nil, 0);
|
||||
if (not skipLoad) and (opcode in [pc_ili,pc_ild]) then
|
||||
GenNative(m_lda_dirX, direct, gLong.disp, nil, 0);
|
||||
GenNative(m_lda_dirX, direct, 0, nil, 0);
|
||||
if opcode in [pc_ili,pc_iil] then
|
||||
GenNative(m_inc_dirX, direct, gLong.disp, nil, 0)
|
||||
GenNative(m_inc_dirX, direct, 0, nil, 0)
|
||||
else
|
||||
GenNative(m_dec_dirX, direct, gLong.disp, nil, 0);
|
||||
GenNative(m_dec_dirX, direct, 0, nil, 0);
|
||||
if (not skipLoad) and (opcode in [pc_iil,pc_idl]) then
|
||||
GenNative(m_lda_dirX, direct, gLong.disp, nil, 0);
|
||||
GenNative(m_lda_dirX, direct, 0, nil, 0);
|
||||
end; {else}
|
||||
if short then
|
||||
GenNative(m_rep, immediate, 32, nil, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user