Bug 21416 – betterC mode program with C++ interface fails to link

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-11-22T23:23:07Z
Last change time
2022-05-10T07:13:11Z
Keywords
betterC, C++, pull
Assigned to
No Owner
Creator
Dibyendu Majumdar

Comments

Comment #0 by mobile — 2020-11-22T23:23:07Z
import core.stdc.stdio : printf; //extern (C++) abstract class A { extern (C++) interface A { void sayHello(); } extern (C++) class B : A { override void sayHello() { printf("hello\n"); } } extern (C) void main() { scope b = new B; b.sayHello(); } Above fails to link with DMD, works with LDC. ~/Software/dmd2/linux/bin64/dmd -betterC interfaces.d /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: interfaces.o:(.data._D10interfaces1A11__InterfaceZ+0x0): undefined reference to `_D14TypeInfo_Class6__vtblZ' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: interfaces.o:(.data._D10interfaces1B6__initZ+0x8): undefined reference to `_D10interfaces1B7__ClassZ' collect2: error: ld returned 1 exit status Error: linker exited with status 1 Tested on RHEL 7.9 DMD64 D Compiler v2.094.1 Replacing 'interface' with 'abstract class' appears to work in DMD, but this should not be necessary since interface is extern (C++).
Comment #1 by alphaglosined — 2021-08-10T16:13:23Z
Minified further: extern(C) void main() {} extern(C++) interface IEntry { } extern(C++) class MyEntryInfo : IEntry { } This is known to work for ldc 1.26.0. The __ClassZ error was introduced between dmd 2.094.0 and 2.097.2.
Comment #2 by dlang-bot — 2022-05-05T13:13:42Z
@RazvanN7 created dlang/dmd pull request #14075 "Fix Issue 21416 - betterC mode program with C++ interface fails to link" fixing this issue: - Fix Issue 21416 - betterC mode program with C++ interface fails to link https://github.com/dlang/dmd/pull/14075
Comment #3 by dlang-bot — 2022-05-10T07:13:11Z
dlang/dmd pull request #14075 "Fix Issue 21416 - betterC mode program with C++ interface fails to link" was merged into master: - 2e6ffd14eba3352d36642d8ffab012e8f1787673 by RazvanN7: Fix Issue 21416 - betterC mode program with C++ interface fails to link https://github.com/dlang/dmd/pull/14075