Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #18410 (Errors initializing an object of RootObj with the C++ backend) [backport] #18836

Merged
merged 5 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/cgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,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})
Expand Down
3 changes: 2 additions & 1 deletion tests/arc/tconst_to_sink.nim
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions tests/cpp/torc.nim
Original file line number Diff line number Diff line change
@@ -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)"