Closed ghost closed 3 years ago
Judging by the assembly code you've posted, operators ++
and --
(in both pre- and post- forms) seem to work properly.
The problem must be that ++arr[2]
is a variadic argument, as it's passed to printf()
; normally the compiler is supposed to pass the address of the argument (as this is how variadic arguments are handled), but for some reason with ++
or --
it passes the value instead (note the load.i
instruction after inc.i
).
I think the most reasonable way to fix this would be to allocate a temporary storage on the heap, store the value there and pass the address to the function - but that's only if the argument is modified with ++
or --
, as otherwise the address of the array cell argument is already in PRI. At least, this is what the compiler already does for single-cell arguments (e.g. in printf("%d", ++x)
the result of ++x
is stored on the heap).
Issue description:
When using pre-increments on arrays, it appears to increment the address instead. No issues with post-increments. Before posting this issue (after typing it) I checked the same thing with decrementing the value. It actually appears that post fails too.
Minimal complete verifiable example (MCVE):
It does increment arr[t2], but it prints incorrect values. (0, 1677215, you get the point) This piece of code:
in amx assembly:
-- After checking it turned out that this:
would print '0' two times (idem dito when incrementing it).
Workspace Information: