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
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/9a1b4467cc175881c5d07f468437a27d5875449f Fix issue 18922: No substitutions for C++ namespaces in different module/file DMD was just comparing the object by their reference instead of their string value. Obviously when a namespace is declared in another module, the reference is different. https://github.com/dlang/dmd/commit/7518facf971ddf0dd2dd5bd8031db5d0782e1fa6 Merge pull request #8332 from Geod24/fix18922 Fix issue 18922: No substitutions for C++ namespaces in different module/file merged-on-behalf-of: Razvan Nitu <[email protected]>
Comment #2 by pro.mathias.lang — 2018-06-08T04:16:40Z
*** Issue 18582 has been marked as a duplicate of this issue. ***