From 23aa562094bdfeca0eb9d2e13b94b5f3208fa575 Mon Sep 17 00:00:00 2001 From: acqn Date: Sat, 24 Feb 2024 15:34:38 +0800 Subject: [PATCH] Fixed potential errors with subtraction evaluation of identifiers at different memory locations. --- src/cc65/expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index a855e5b3c..f6c681db8 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -3272,7 +3272,7 @@ static void parsesub (ExprDesc* Expr) /* The right hand side is constant. Check left hand side. */ if (ED_IsQuasiConst (Expr)) { /* We can't do all 'ptr1 - ptr2' constantly at the moment */ - if (Expr->Sym == Expr2.Sym) { + if (ED_GetLoc (Expr) == ED_GetLoc (&Expr2) && Expr->Sym == Expr2.Sym) { Expr->IVal = (Expr->IVal - Expr2.IVal) / rscale; /* Get rid of unneeded flags etc. */ ED_MakeConstAbsInt (Expr, Expr->IVal);