From d7634c1bd42dd5367d10283a2efc353a0a83aed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20M=20G=C3=B3mez?= Date: Wed, 30 Aug 2023 06:22:36 +0100 Subject: [PATCH] fixes an issue where sometimes wasMoved produced bad codegen for cpp (#22587) --- compiler/ccgexprs.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index be04cee9ee..2492eebaee 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2324,7 +2324,10 @@ proc genMove(p: BProc; n: PNode; d: var TLoc) = s = "$1, $1Len_0" % [rdLoc(a)] linefmt(p, cpsStmts, "$1($2);$n", [rdLoc(b), s]) else: - linefmt(p, cpsStmts, "$1($2);$n", [rdLoc(b), byRefLoc(p, a)]) + if p.module.compileToCpp: + linefmt(p, cpsStmts, "$1($2);$n", [rdLoc(b), rdLoc(a)]) + else: + linefmt(p, cpsStmts, "$1($2);$n", [rdLoc(b), byRefLoc(p, a)]) else: let flags = if not canMove(p, n[1], d): {needToCopy} else: {} genAssignment(p, d, a, flags)