[Issue 22815] New: extern(C++) constructor cannot be used from C++ (no init symbol blit)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 22 22:31:52 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22815
Issue ID: 22815
Summary: extern(C++) constructor cannot be used from C++ (no
init symbol blit)
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: kinke at gmx.net
In D, compiler/druntime pre-initialize each class instance (extern(D) and
extern(C++) etc.) by blitting the init symbol (incl. vptr) before invoking a
constructor.
In C++, the constructor initializes the fields directly. So if we call a C++
one from a matching extern(C++) declaration in D, we do a little bit of extra
work with the pre-init blit. The real issue is that invoking an extern(C++)
definition from C++ might likely result in incomplete initialization /
undefined behavior.
Note that simply inserting the full blit as first statement in each extern(C++)
ctor isn't desirable in case of class hierarchies with super(…) calls, or other
this(…) calls. Related in this regard:
https://issues.dlang.org/show_bug.cgi?id=18966
Maybe we should start with deprecating extern(C++) ctor *definitions* for now.
Declaring one defined in C++ is fine.
--
More information about the Digitalmars-d-bugs
mailing list