diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 30326c8db0..b0964f97be 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -370,7 +370,7 @@ proc expressionsNeedsTmp(p: BProc, a: TLoc): TLoc = proc genArgStringToCString(p: BProc, n: PNode; result: var Builder; needsTmp: bool) {.inline.} = var a = initLocExpr(p, n[0]) let tmp = withTmpIfNeeded(p, a, needsTmp) - let ra = if p.config.isDefined("nimsso"): addrLoc(p.config, tmp) else: tmp.rdLoc + let ra = if p.config.isDefined("nimsso"): byRefLoc(p, tmp) else: tmp.rdLoc result.addCall(cgsymValue(p.module, "nimToCStringConv"), ra) proc genArg(p: BProc, n: PNode, param: PSym; call: PNode; result: var Builder; needsTmp = false) = diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index b517fbd219..941327341e 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2736,7 +2736,7 @@ proc genConv(p: BProc, e: PNode, d: var TLoc) = proc convStrToCStr(p: BProc, n: PNode, d: var TLoc) = var a: TLoc = initLocExpr(p, n[0]) - let arg = if p.config.isDefined("nimsso"): addrLoc(p.config, a) else: rdLoc(a) + let arg = if p.config.isDefined("nimsso"): byRefLoc(p, a) else: rdLoc(a) putIntoDest(p, d, n, cgCall(p, "nimToCStringConv", arg), a.storage) diff --git a/tests/system/tnimsso.nim b/tests/system/tnimsso.nim new file mode 100644 index 0000000000..ca9d64faec --- /dev/null +++ b/tests/system/tnimsso.nim @@ -0,0 +1,7 @@ +discard """ + matrix: "-d:nimsso" + targets: "c cpp" +""" + +var s = "abc" +discard s.cstring \ No newline at end of file