From 42d38acb19ff2ff1ec9b0bf3c103d3a54dbb8273 Mon Sep 17 00:00:00 2001 From: Mingjie Shen Date: Mon, 25 Mar 2024 00:18:48 -0400 Subject: [PATCH] Fixed incorrect operator precedence Before this commit, if __optr is == or !=, the if condition on line 1052 is unintendedly interpreted as ((real_t)(opndv1.data.integer __optr opndv2.data.integer) == (real_t)opndv1.data.integer) __optr (real_t)opndv2.data.integer because the associativity of != and == operators in C is left-to-right. Fixed by fully parenthesize the complex comparison expression. --- core/my_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/my_basic.c b/core/my_basic.c index 9f9fc02..9594156 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -1049,7 +1049,7 @@ static _object_t* _exp_assign = 0; do { \ _instruct_common(__tuple) \ if(opndv1.type == _DT_INT && opndv2.type == _DT_INT) { \ - if((real_t)(opndv1.data.integer __optr opndv2.data.integer) == (real_t)opndv1.data.integer __optr (real_t)opndv2.data.integer) { \ + if((real_t)(opndv1.data.integer __optr opndv2.data.integer) == ((real_t)opndv1.data.integer __optr (real_t)opndv2.data.integer)) { \ val->type = _DT_INT; \ val->data.integer = opndv1.data.integer __optr opndv2.data.integer; \ } else { \