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 */