diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-03-16 13:23:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-16 06:23:15 +0100 |
commit | f639cf063f66a160550bcf8955eb3446ca101cc2 (patch) | |
tree | 8100285884ce228a046566bb1c277435c420c300 /compiler | |
parent | b387bc49b5425a7b555972184f5f6078b14d4a8b (diff) | |
download | Nim-f639cf063f66a160550bcf8955eb3446ca101cc2.tar.gz |
fixes #23401; prevents nrvo for cdecl procs (#23409)
fixes #23401
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgtypes.nim | 5 |
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 |