Bug 21412 – betterC mode program with C++ interface/class crashes

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-11-21T23:33:38Z
Last change time
2020-11-22T00:01:30Z
Keywords
betterC, C++
Assigned to
No Owner
Creator
Dibyendu Majumdar

Comments

Comment #0 by mobile — 2020-11-21T23:33:38Z
Following code builds in -betterC mode but crashes. Tested on RHEL 7.9, DMD64 D Compiler v2.094.1. import core.stdc.stdio : printf; extern (C++) abstract class A { void sayHello(); } extern (C++) class B : A { @disable this(); override void sayHello() { printf("hello\n"); } } extern (C) void main() { B b; b.sayHello(); }
Comment #1 by mobile — 2020-11-21T23:34:59Z
According to documentation betterC mode supports: Interfacing with C++ COM classes and C++ classes
Comment #2 by mobile — 2020-11-21T23:36:20Z
I tried with / without @disable this(); Same result
Comment #3 by destructionator — 2020-11-21T23:51:02Z
that's just an ordinary null pointer.....
Comment #4 by mobile — 2020-11-21T23:56:28Z
I assume you mean that it needs to be coded like this? import core.stdc.stdio : printf; extern (C++) abstract class A { void sayHello(); } extern (C++) class B : A { override void sayHello() { printf("hello\n"); } } extern (C) void main() { scope b = new B; b.sayHello(); } This works