sdcc incorrectly compiles code that has a
post-increment operator (eg. i++) used to compute the
lvalue for an assignment-operator statement.
For example, the following code:
a[i++] |= value;
may be compiled incorrectly. The output code will
correctly store its result in a[i] but will read one of
its operands from a[i+1] rather than a[i].
I have seen this bug with the following version of sdcc:
$ sdcc --version
SDCC
mcs51/gbz80/z80/avr/ds390/pic14/pic16/TININative/xa51/ds400
2.3.5 (Aug 1 2003)\
(UNIX)
The attached file demonstrates the bug in a simple C
program. It also includes a comment showing the
generated .asm file and the bug it contains.
Thanks,
-Carl
Carl Worth <cwort@isi.edu>
Demonstration program for assignment operator bug.
Logged In: NO
Typo correction:
Carl Worth <cworth@isi.edu>
Logged In: YES
user_id=635249
Although the code generation could be improved, it is now at
least correct. See ChangeLog 1.501 for the relevent files
updated.