www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18922] New: dmd doesn't do substitutions for C++ namespaces

https://issues.dlang.org/show_bug.cgi?id=18922

          Issue ID: 18922
           Summary: dmd doesn't do substitutions for C++ namespaces in
                    different module/file
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

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.

--
May 30 2018