Bug 19134 – [C++] static const y = new Derived(); ->pointer cast from const(Derived) to immutable(void*)** is not supported at compile time
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-08-02T01:34:30Z
Last change time
2018-08-27T04:30:38Z
Assigned to
No Owner
Creator
Nicholas Wilson
Comments
Comment #0 by iamthewilsonator — 2018-08-02T01:34:30Z
https://forum.dlang.org/post/[email protected]https://run.dlang.io/is/dSVruv
Works in DMD 2.080, regressed in DMD 2.081.
extern(C++) {
class Base {
this() {}
void consumeAVtblSlot() const {}
}
class Derived : Base {
this() {}
}
}
void main()
{
static const y = new Y();
}
fails with
Error: pointer cast from const(Y) to immutable(void*)** is not supported at compile time
commenting out the constructor of X makes compilation succeed. Removing extern C++ makes compilation succeed.
Comment #1 by iamthewilsonator — 2018-08-02T01:41:26Z
Comment #4 by github-bugzilla — 2018-08-27T04:30:34Z
Commits pushed to master at https://github.com/dlang/dmdhttps://github.com/dlang/dmd/commit/b952c845f77264d40253e2e144625fdb0c301804
Fix Issue 19134
And revert to D vptr semantics in constructors of extern(C++) classes,
i.e., call the most derived override in base constructors. 2.081
introduced a breaking change here, using the most derived override
before the super() call and the current class' afterwards.
The proper mid-term solution is probably to emit fully C++-compatible
constructors for extern(C++) classes, calling the super ctor right at
the start and then blitting vptr and class-specific fields from the
init symbol. extern(C++) classes (and structs) should get an implicit
default ctor (only if there's no other ctor in the class case).
extern(C++) classes could then be allocated and properly constructed via
C++ `new`; struct declarations in C++ headers for extern(C++) structs
wouldn't need to duplicate the field initializers and could simply
declare the default ctor (emitted by the D compiler and blitting the
init symbol).
https://github.com/dlang/dmd/commit/50833f0a98df9ac1f1c78db4dd24743aad300539
Merge pull request #8533 from kinke/fix19134
[stable] Fix Issue 19134 - [C++] static const y = new Derived(); ->pointer cast from const(Derived) to immutable(void*)** is not supported at compile time
merged-on-behalf-of: Rainer Schuetze <[email protected]>