Bug 18922 – dmd doesn't do substitutions for C++ namespaces in different module/file
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-31T04:15:11Z
Last change time
2018-06-08T04:16:40Z
Keywords
C++
Assigned to
No Owner
Creator
Mathias LANG
Comments
Comment #0 by pro.mathias.lang — 2018-05-31T04:15:11Z
The following test case:
```
extern(C++, testns)
{
struct MyStruct { int i; }
void func (MyStruct x) {}
}
```
Correctly mangles `func` as `__ZN6testns4funcENS_8MyStructE`
However, if `MyStruct` is defined in another module, as the following example shows:
```
// File cpp.d
module cpp;
import data;
extern(C++, testns)
{
void func (MyStruct x) {}
}
```
```
// File data.d
module data;
extern(C++, testns):
struct MyStruct { int i; }
```
dmd will mangle `func` as `_ZN6testns4funcEN6testns8MyStructE`, not doing the namespace substitution correctly.
Tested on Mac OSX & Linux x64 with DMD 2.080.
This is a blocker for porting any large C++ code base to D, hence classified as major.
Comment #1 by github-bugzilla — 2018-06-06T18:44:44Z