diff --git a/src/cc65/assignment.c b/src/cc65/assignment.c index e51dde9ab..a66c495da 100644 --- a/src/cc65/assignment.c +++ b/src/cc65/assignment.c @@ -104,10 +104,16 @@ 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 */ 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 */ 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