From 7854a534349ba5607f868eb4ffa4bf58c9b5830b Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Wed, 18 Jun 2025 11:53:44 +0200 Subject: [PATCH] When studying expressions and recalculating the address size for a symbol expression, use the symbol address size only if it is smaller than the one that was calculated. --- src/ca65/studyexpr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ca65/studyexpr.c b/src/ca65/studyexpr.c index 40e9b7aab..f4376e221 100644 --- a/src/ca65/studyexpr.c +++ b/src/ca65/studyexpr.c @@ -610,12 +610,13 @@ static void StudySymbol (ExprNode* Expr, ExprDesc* D) DumpExpr (Expr, SymResolve); } - /* If the symbol has an explicit address size, use it. This may - ** lead to range errors later (maybe even in the linker stage), if - ** the user lied about the address size, but for now we trust him. + /* If the symbol has an explicit address size that is smaller than + ** the one found, use it. This may lead to range errors later + ** (maybe even in the linker stage) if the user lied about the + ** address size, but for now we trust him. */ AddrSize = GetSymAddrSize (Sym); - if (AddrSize != ADDR_SIZE_DEFAULT) { + if (AddrSize != ADDR_SIZE_DEFAULT && AddrSize < D->AddrSize) { D->AddrSize = AddrSize; } }