September 12, 2019 [Issue 20208] New: extern (C++) copy constructor bad mangling for dmd | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20208 Issue ID: 20208 Summary: extern (C++) copy constructor bad mangling for dmd Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: edi33416@gmail.com DMD is incorrectly mangling the copy constructor of an `extern (C++) struct`. Please see the details below c.d ``` module c; extern (C++) struct A { int x; this(int x) { this.x = x; } this(const ref A rhs) { this.x = rhs.x; } ~this() { } } ``` c.h ``` struct A { _d_int x; A(_d_int x); A(const A& rhs); ~A(); }; ``` tc.cpp ``` #include "c.h" int main(int argc, char *argv[]) { A x = A(42); A y = x; return 0; } ``` I'm running on Ubuntu 18.04.1 LTS Compiling `.d` with DMD64 D Compiler v2.086.0-1241-g08360654e custdmd2 -c -betterC c.d Compiling `.cpp` with g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0 g++ -c tc.cpp Linking the two objects together `g++ tc.o c.o` results in the linker error tc.o: In function `main': tc.cpp:(.text+0x3f): undefined reference to `A::A(A const&)' collect2: error: ld returned 1 exit status Results of `nm` on objects nm c.o [...] 0000000000000000 W _ZN1AC2ERKS_ nm tc.o [...] U _ZN1AC1ERKS_ Compiling the `.d` module with LDC - the LLVM D compiler (1.14.0) based on DMD v2.084.1 and LLVM 7.0.1 ldc2 -betterC -c c.d The resulted `c.o` object correctly links with the g++ generated one. The output of `nm c.o` on the ldc2 generated object is [...] 0000000000000000 T _ZN1AC1ERKS_ -- |
Copyright © 1999-2021 by the D Language Foundation