Menu ▾ ▴

#2240 ++a is not treated as an rvalue

closed-fixed
None
Front-end
5
2023-07-29
2014-01-04
No

After a long discussion on the mailing list
https://sourceforge.net/p/sdcc/mailman/message/31801282/
this came out.

The following code should generate error 10: lvalue required:

char E=0, b=1;
++E = b;

as the spec says that ++E is equivalent to (E+=1) which is not an lvalue.

Related

Wiki: NGI0-Entrust-SDCC

Discussion

  • Maarten Brock

    Maarten Brock - 2014-01-05

    After I made ++E an rvalue *++E started to fail. I believe this is wrong because * should turn an rvalue into an lvalue, right ? But this check in SDCCast.c line 3666 is already present from day 1 ?! Further I get the feeling most expressions are marked neither lvalue nor rvalue and slip through many tests.

    It might also be that I totally misunderstand the lvalue and rvalue fields and that they don't mark the AST to BE an lvalue/rvalue but to REQUIRE an lvalue/rvalue.

     
  • Maarten Brock

    Maarten Brock - 2014-01-05

    The same goes for (E++)[1] which fails in SDCCast.c line 3120 after my mod. But (p+1)[1] is still ok, because (p+1) is marked neither lvalue nor rvalue.

     
  • Maarten Brock

    Maarten Brock - 2014-01-05

    I really don't get it. In SDCCast.c lines 3229-3243 the operand of ++ or -- is marked lvalue, no matter if it really is one or not. IMO that is too late. It should check whether the operand is an lvalue instead. And IMO it should mark the ast as rvalue. Can anyone explain?

     
  • Sergey Belyashov

    Bug is still exists.
    Any ideas?

     
  • Philipp Klaus Krause

    While I remember having fixed some lvalue vs. rvalue stuff a few months ago, this bug still exists in current SDCC.

     
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    My rvalue fixes a few month ago might not have been fixed this bug, but nearly. Just one more line was needed. Fixed in [r14248].

     

    Related

    Commit: [r14248]


Log in to post a comment.