Bug 18896 – extern(C++) always mangles classes as pointer
Status
RESOLVED
Resolution
WONTFIX
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-23T07:13:11Z
Last change time
2021-03-25T00:28:49Z
Keywords
C++, industry
Assigned to
No Owner
Creator
Manu
Comments
Comment #0 by turkeyman — 2018-05-23T07:13:11Z
C++:
---------------------------------------
class C {};
template <typename T>
void create(T** x);
---------------------------------------
D:
---------------------------------------
extern(C++):
class C {}
void create(T)(T* x);
---------------------------------------
Trouble is; in CPP, the template mangles as a C, but in D, the class
mangles as C*... so the mangling doesn't match.
`template<typename Class>` is an unbelievably common occurrence in
C++... but how do we express a signature that mangles correctly in D?
D always mangles `Class` as `Class*`... which changes the signature.
We really need to offer a solution here, this is a gaping hole!
Comment #1 by pro.mathias.lang — 2018-10-22T18:27:25Z
Renamed to make it a bit more generic.
This is also a problem when `ref` is used for passing the class around.
E.g. `foo(MyClass&)` cannot be represented in D, which is very limiting.
Comment #2 by pro.mathias.lang — 2020-02-19T05:33:48Z
*** Issue 19161 has been marked as a duplicate of this issue. ***
Comment #3 by iamthewilsonator — 2021-03-25T00:28:49Z
this can be worked around by pragma(mangle, ...) now.