summary refs log tree commit diff stats
path: root/compiler/ccgexprs.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2020-03-10 11:10:52 +0100
committerAndreas Rumpf <rumpf_a@web.de>2020-03-11 09:26:57 +0100
commit60f8fdcdabf99ae60f7a743cfd682bd7c320408b (patch)
treeaf457daf9cf81c08b550b38654fbc6d422fbc5bb /compiler/ccgexprs.nim
parent861a5340fec22cbca014bffc84f61536a5aa3e37 (diff)
downloadNim-60f8fdcdabf99ae60f7a743cfd682bd7c320408b.tar.gz
fixes #13240
Diffstat (limited to 'compiler/ccgexprs.nim')
-rw-r--r--compiler/ccgexprs.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index f133b97a2..1bed4bc6c 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1340,7 +1340,14 @@ proc genObjConstr(p: BProc, e: PNode, d: var TLoc) =
   #echo rendertree e, " ", e.isDeepConstExpr
   # inheritance in C++ does not allow struct initialization so
   # we skip this step here:
-  if not p.module.compileToCpp:
+  if not p.module.compileToCpp and optSeqDestructors notin p.config.globalOptions:
+    # disabled optimization: it is wrong for C++ and now also
+    # causes trouble for --gc:arc, see bug #13240
+    #[
+      var box: seq[Thing]
+      for i in 0..3:
+        box.add Thing(s1: "121") # pass by sink can mutate Thing.
+    ]#
     if handleConstExpr(p, e, d): return
   var t = e.typ.skipTypes(abstractInstOwned)
   let isRef = t.kind == tyRef