summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/cgen.nim3
-rw-r--r--tests/arc/tconst_to_sink.nim3
-rw-r--r--tests/cpp/torc.nim15
3 files changed, 19 insertions, 2 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 412a428da..b669483cc 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -363,7 +363,8 @@ proc genObjectInit(p: BProc, section: TCProcSection, t: PType, a: var TLoc,
     else:
       linefmt(p, section, "$1.m_type = $2;$n", [r, genTypeInfoV1(p.module, t, a.lode.info)])
   of frEmbedded:
-    if optTinyRtti in p.config.globalOptions:
+    # inheritance in C++ does not allow struct initialization: bug #18410
+    if not p.module.compileToCpp and optTinyRtti in p.config.globalOptions:
       var tmp: TLoc
       if mode == constructRefObj:
         let objType = t.skipTypes(abstractInst+{tyRef})
diff --git a/tests/arc/tconst_to_sink.nim b/tests/arc/tconst_to_sink.nim
index ddcc46e67..25f659341 100644
--- a/tests/arc/tconst_to_sink.nim
+++ b/tests/arc/tconst_to_sink.nim
@@ -1,6 +1,7 @@
 discard """
   output: '''@[(s1: "333", s2: ""), (s1: "abc", s2: "def"), (s1: "3x", s2: ""), (s1: "3x", s2: ""), (s1: "3x", s2: ""), (s1: "3x", s2: ""), (s1: "lastone", s2: "")]'''
-  cmd: "nim c --gc:arc $file"
+  matrix: "--gc:arc"
+  targets: "c cpp"
 """
 
 # bug #13240
diff --git a/tests/cpp/torc.nim b/tests/cpp/torc.nim
new file mode 100644
index 000000000..7fc474f94
--- /dev/null
+++ b/tests/cpp/torc.nim
@@ -0,0 +1,15 @@
+discard """
+  targets: "cpp"
+  matrix: "--gc:orc"
+"""
+
+import std/options
+
+# bug #18410
+type
+  O = object of RootObj
+   val: pointer
+
+proc p(): Option[O] = none(O)
+
+doAssert $p() == "none(O)"
\ No newline at end of file