summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorJuan M Gómez <info@jmgomez.me>2023-08-30 06:22:36 +0100
committerGitHub <noreply@github.com>2023-08-30 07:22:36 +0200
commitd7634c1bd42dd5367d10283a2efc353a0a83aed2 (patch)
tree1eb675ed3fe67de756427ea23386cd9abd6b8137 /compiler
parenta7a0105d8c538ce9d0ac26ba73409107d55d3c8c (diff)
downloadNim-d7634c1bd42dd5367d10283a2efc353a0a83aed2.tar.gz
fixes an issue where sometimes wasMoved produced bad codegen for cpp (#22587)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index be04cee9e..2492eebae 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)