Browse Source

Fix issue #244 with constant array comparisons

gingerBill 7 years ago
parent
commit
1ee60663bb
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/check_expr.cpp

+ 5 - 1
src/check_expr.cpp

@@ -1553,7 +1553,11 @@ void check_comparison(CheckerContext *c, Operand *x, Operand *y, TokenKind op) {
 	} else {
 	} else {
 		if (x->mode == Addressing_Constant &&
 		if (x->mode == Addressing_Constant &&
 		    y->mode == Addressing_Constant) {
 		    y->mode == Addressing_Constant) {
-			x->value = exact_value_bool(compare_exact_values(op, x->value, y->value));
+			if (is_type_constant_type(x->type)) {
+				x->value = exact_value_bool(compare_exact_values(op, x->value, y->value));
+			} else {
+				x->mode = Addressing_Value;
+			}
 		} else {
 		} else {
 			x->mode = Addressing_Value;
 			x->mode = Addressing_Value;