From 3a52c143fb3b0e2f4d2e9e2ab4bc068a6e775b9a Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:25:12 +0100 Subject: [PATCH 1/3] Fix #2566. --- src/cc65/assignment.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc65/assignment.c b/src/cc65/assignment.c index e51dde9ab..e9b200b0f 100644 --- a/src/cc65/assignment.c +++ b/src/cc65/assignment.c @@ -104,9 +104,9 @@ static void CopyStruct (ExprDesc* LExpr, ExprDesc* RExpr) } else { - /* The rhs cannot happen to be loaded in the primary as it is too big */ + /* Load the address of rhs into the primary */ + ED_AddrExpr (RExpr); if (!ED_IsLocExpr (RExpr)) { - ED_AddrExpr (RExpr); LoadExpr (CF_NONE, RExpr); } From 447b6e557302571e2b96a2a748920c6894f611c8 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Sun, 5 Jan 2025 16:27:36 +0100 Subject: [PATCH 2/3] More explicit solution. The first one was a bit hackish. --- src/cc65/assignment.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc65/assignment.c b/src/cc65/assignment.c index e9b200b0f..a66c495da 100644 --- a/src/cc65/assignment.c +++ b/src/cc65/assignment.c @@ -105,9 +105,15 @@ static void CopyStruct (ExprDesc* LExpr, ExprDesc* RExpr) } else { /* Load the address of rhs into the primary */ - ED_AddrExpr (RExpr); if (!ED_IsLocExpr (RExpr)) { + ED_AddrExpr (RExpr); LoadExpr (CF_NONE, RExpr); + } else if (RExpr->IVal != 0) { + /* We have an expression in the primary plus a constant + ** offset. Adjust the value in the primary accordingly. + */ + g_inc (CF_PTR | CF_CONST, RExpr->IVal); + RExpr->IVal = 0; } /* Push the address of the rhs as the source of memcpy */ From 1556c8ac7cec6d0c3de4d9ca9fefb05797ff7d38 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Sun, 5 Jan 2025 17:04:31 +0100 Subject: [PATCH 3/3] Move the test from "todo" to "val" since it shouldn't fail any longer. --- test/{todo => val}/bug2566.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{todo => val}/bug2566.c (100%) diff --git a/test/todo/bug2566.c b/test/val/bug2566.c similarity index 100% rename from test/todo/bug2566.c rename to test/val/bug2566.c