From b6307dded34be6c6cd7e7c1d51ca204002c62883 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 9 Jul 2017 00:45:14 +0200 Subject: [PATCH] fixes #6037 --- compiler/ccgexprs.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 043064d982..0ec16710f6 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2126,7 +2126,14 @@ proc expr(p: BProc, n: PNode, d: var TLoc) = if n.sons[0].kind != nkEmpty: genLineDir(p, n) var a: TLoc - initLocExpr(p, n.sons[0], a) + if n[0].kind in nkCallKinds: + # bug #6037: do not assign to a temp in C++ mode: + incl a.flags, lfSingleUse + genCall(p, n[0], a) + if lfSingleUse notin a.flags: + line(p, cpsStmts, a.r & ";" & tnl) + else: + initLocExpr(p, n.sons[0], a) of nkAsmStmt: genAsmStmt(p, n) of nkTryStmt: if p.module.compileToCpp and optNoCppExceptions notin gGlobalOptions: