Correctly increment/decrement pointers to large (>=64KiB) types.

Previously, the logic for this was incorrect and would lead to a null pointer dereference in the compiler. In most cases the generated code would not actually change the pointer.

The following program demonstrates the issue:

#include <stdio.h>
#pragma memorymodel 1
typedef char bigarray[0x20000];
bigarray big[5];
int main(void) {
        bigarray *p = big;
        p++;
        printf("%p %p\n", (void*)big, (void*)p);
}
This commit is contained in:
Stephen Heumann 2019-12-23 19:59:18 -06:00
parent 13a14d9389
commit 91094e9292

View File

@ -2535,7 +2535,7 @@ var
Gen0(pc_adl)
else
Gen0(pc_sbl);
with tree^.left^.id^ do
with tree^.id^ do
case storage of
stackFrame, parameter:
Gen2t(pc_cop, lln, 0, cgULong);