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.
Comment #1 by robert.schadek — 2024-12-13T19:21:09Z