www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20685] New: Missing const in name mangling with C++ when

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

          Issue ID: 20685
           Summary: Missing const in name mangling with C++ when using
                    templates
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

cpp.cpp:

-----
template<typename K, typename V>
void cpp_test (const K&, const V&)
{
}

#define INSTANTIATE(K, V) template void cpp_test<K, V>(const K&, const V&);
INSTANTIATE(int, int)
-----

d.d:
-----
extern(C++) void cpp_test (K, V)(ref const K key, ref const V value);

void main ()
{
    int i;
    cpp_test(i, i);
}
-----

$ g++ -c cpp.cpp -ocpp.o
$ dmd -c d.d -ofd.o
$ nm cpp.o | grep cpp_test
0000000000000000 W _Z8cpp_testIiiEvRKT_RKT0_
$ nm d.o | grep cpp_test
                 U _Z8cpp_testIiiEvRT_RT0_

It seems that 'const' is missing.

It seems similar to https://issues.dlang.org/show_bug.cgi?id=20336, only that
here templates are involved.

--
Mar 18