[Issue 21416] New: betterC mode program with C++ interface fails to link
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 22 23:23:07 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21416
Issue ID: 21416
Summary: betterC mode program with C++ interface fails to link
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: mobile at majumdar.org.uk
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++).
--
More information about the Digitalmars-d-bugs
mailing list