Bug 20679 – C++ name mangling mismatch with templated return type

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-03-17T08:23:15Z
Last change time
2024-12-13T19:07:47Z
Assigned to
No Owner
Creator
Andrej Mitrovic
Moved to GitHub: dmd#19681 →

Comments

Comment #0 by andrej.mitrovich — 2020-03-17T08:23:15Z
cpp.cpp: ----- #include <unordered_map> template<typename K, typename V> std::unordered_map<K, V>* cpp_unordered_map_create () { return new std::unordered_map<K, V>(); } #define CPPUNORDEREDMAPCREATEINST(K, V) template std::unordered_map<K, V>* cpp_unordered_map_create<K, V>(); CPPUNORDEREDMAPCREATEINST(int, int) ----- test.d ----- import std.meta; private template StdNS () { version (darwin) alias StdNS = AliasSeq!(`std`, `__1`); else alias StdNS = AliasSeq!(`std`); } extern(C++, (StdNS!())) struct allocator (T) {} extern(C++, (StdNS!())) struct pair (T1, T2) {} extern(C++, (StdNS!())) struct hash (T) {} extern(C++, (StdNS!())) struct equal_to (T = void) {} extern(C++, (StdNS!())) { struct unordered_map (Key, T, Hash = hash!Key, KeyEqual = equal_to!Key, Allocator = allocator!(pair!(const Key, T))) { void* ptr; } } pure nothrow @nogc @safe extern(C++) unordered_map!(K, V)* cpp_unordered_map_create (K, V)(); void main () { auto map = cpp_unordered_map_create!(int, int); } ----- There seems to be an issue with substitution: $ nm test.o | grep "cpp_unordered_map_create" _Z24cpp_unordered_map_createIiiEPSt13unordered_mapIT_T0_St4hashIiESt8equal_toIiESaISt4pairIKiiEEEv $ nm cpp.o | grep "cpp_unordered_map_create" _Z24cpp_unordered_map_createIiiEPSt13unordered_mapIT_T0_St4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S2_EEEv On the C++ side S1_ and S2_ are used in place of just 'i' for the two integer types.
Comment #1 by robert.schadek — 2024-12-13T19:07:47Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19681 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB