www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16944] New: extern(C++) with template produces wrong mangleof

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

          Issue ID: 16944
           Summary: extern(C++) with template produces wrong mangleof
           Product: D
           Version: D2
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

originally reported here:
http://forum.dlang.org/post/mailman.594.1480720320.9448.digitalmars-d-learn puremagic.com:

Not sure what's the difference bw _Z21test_D20161202T141925IiET_S0_ and
_Z21test_D20161202T141925IiEii but mangleof produces the one that's not in the
library produced:

test.cpp:
```
template<typename T>
T test_D20161202T141925(T a);
template int test_D20161202T141925<int>(int);
```

clang++ -shared -o libtest.so test.cpp

c++filt _Z21test_D20161202T141925IiET_S0_
int test_D20161202T141925<int>(int)

c++filt _Z21test_D20161202T141925IiEii
int test_D20161202T141925<int>(int)

nm libtest.so|grep test_D20161202T141925:
0000000000000ae0 W _Z21test_D20161202T141925IiET_S0_
```

test.d:
```
extern(C++){
  void test_D20161202T141743();
  T test_D20161202T141925(T)(T a);
}

void test(){
  assert(test_D20161202T141925!int.mangleof ==
"_Z21test_D20161202T141925IiEii");
// but I would expect _Z21test_D20161202T141925IiET_S0_ (otherwise,
undefined symbol)
}
```

--
Dec 02 2016