[Issue 20679] New: C++ name mangling mismatch with templated return type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 17 08:23:15 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20679
Issue ID: 20679
Summary: C++ name mangling mismatch with templated return type
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: andrej.mitrovich at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list