summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-03-16 13:23:15 +0800
committerGitHub <noreply@github.com>2024-03-16 06:23:15 +0100
commitf639cf063f66a160550bcf8955eb3446ca101cc2 (patch)
tree8100285884ce228a046566bb1c277435c420c300 /compiler
parentb387bc49b5425a7b555972184f5f6078b14d4a8b (diff)
downloadNim-f639cf063f66a160550bcf8955eb3446ca101cc2.tar.gz
fixes #23401; prevents nrvo for cdecl procs (#23409)
fixes #23401
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgtypes.nim5
1 files changed, 4 insertions, 1 deletions
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