From f639cf063f66a160550bcf8955eb3446ca101cc2 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sat, 16 Mar 2024 13:23:15 +0800 Subject: fixes #23401; prevents nrvo for cdecl procs (#23409) fixes #23401 --- compiler/ccgtypes.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index ae9349b43..3d1a3af6f 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -275,7 +275,10 @@ proc isInvalidReturnType(conf: ConfigRef; typ: PType, isProc = true): bool = {tyVar, tyLent, tyRef, tyPtr}) of ctStruct: let t = skipTypes(rettype, typedescInst) - if rettype.isImportedCppType or t.isImportedCppType: return false + if rettype.isImportedCppType or t.isImportedCppType or + (typ.callConv == ccCDecl and conf.selectedGC in {gcArc, gcAtomicArc, gcOrc}): + # prevents nrvo for cdecl procs; # bug #23401 + return false result = containsGarbageCollectedRef(t) or (t.kind == tyObject and not isObjLackingTypeField(t)) else: result = false -- cgit 1.4.1-2-gfad0