Menu

#607 BUG: Post-increment in lvalue for assignment operator

closed-fixed
5
2013-05-25
2003-10-07
Anonymous
No

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>

Discussion

  • Nobody/Anonymous

    Demonstration program for assignment operator bug.

     
  • Nobody/Anonymous

    Logged In: NO

    Typo correction:

    Carl Worth <cworth@isi.edu>

     
  • Erik Petrich

    Erik Petrich - 2003-11-11
    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: open --> closed-fixed
     
  • Erik Petrich

    Erik Petrich - 2003-11-11

    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.

     

Log in to post a comment.