#3 Operator precedence is incorrect

closed-fixed
nobody
None
5
2003-02-27
2002-11-29
Peder Holt
No

The expression: 8/4*2 becomes 1 (4*2 is executed before 8/4) this
is due to an error in the macro BINARY_OP:
#define
BINARY_OP(PRECEDENCE,EXPRESSION,TYPE) \ else
if ((EXPRESSION) && precedence <= PRECEDENCE) {
....

The correct expression should be:
#define
BINARY_OP(PRECEDENCE,EXPRESSION,TYPE) \ else
if ((EXPRESSION) && precedence < PRECEDENCE) {
....

The expression 8/4*2 now correctly becomes 4.

Discussion

  • Andreas Kloeckner

    Logged In: YES
    user_id=16259

    Fixed in CVS

     
  • Andreas Kloeckner

    • status: open --> open-fixed
     
  • Andreas Kloeckner

    • status: open-fixed --> closed-fixed
     

Log in to post a comment.