Fix codegen error for some indirect accesses to 64-bit values.
The code was not properly adding in the offset of the 64-bit value from the pointed-to location, so the wrong memory location would be accessed. This affected indirect accesses to non-initial structure members, when used as operands to certain operations. Here is an example showing the problem: #include <stdio.h> long long x = 123456; struct S { long long a; long long b; } s = {0, 123456}; int main(void) { struct S *sp = &s; if (sp->b != x) { puts("error"); } }
This commit is contained in:
parent
50636bd28b
commit
77e0b8fc59
1
Gen.pas
1
Gen.pas
|
@ -321,6 +321,7 @@ case op^.opcode of
|
|||
loc := LabelToDisp(op^.left^.r) + op^.left^.q;
|
||||
if (op^.left^.opcode <> pc_lod) or (loc > 255) then
|
||||
Error(cge1);
|
||||
offset := offset + op^.q;
|
||||
if offset = 0 then
|
||||
GenNative(mop, direct, loc, nil, 0)
|
||||
else begin
|
||||
|
|
2
cc.notes
2
cc.notes
|
@ -1622,6 +1622,8 @@ If you use #pragma debug 0x0010 to enable stack check debug code, the compiler w
|
|||
|
||||
16. When an expression of const- or volatile-qualified struct or union type was passed as a function parameter, incorrect code would be generated. This could lead to incorrect program behavior or crashes.
|
||||
|
||||
17. Incorrect code could sometimes be generated if a long long or unsigned long long value was a non-initial member of a structure, and it was accessed through a pointer to the structure and used as an operand of certain arithmetic, bitwise, or comparison operators.
|
||||
|
||||
-- Bugs from C 2.1.1 B3 that have been fixed in C 2.2.0 ---------------------
|
||||
|
||||
1. There were various bugs that could cause incorrect code to be generated in certain cases. Some of these were specific to certain optimization passes, alone or in combination.
|
||||
|
|
Loading…
Reference in New Issue