C++ mangling is wrong when a function takes an argument of type T (templated) and when the typeof(T) is a class.
Test case:
```
extern(C++) class Symbol {}
extern(C++) class Symbol2 {}
extern(C++) class A(T) {
void foo_template(T t) {}
void foo_incorrect(Symbol t) {}
void foo_correct(Symbol2 t) {}
}
A!int b_works;
A!Symbol b_incorrect;
```
Then running
> dmd -c cpp.d -ofcpp.o
> nm cpp.o | c++filt
gives the correct mangling for A!int:
A<int>::foo_correct(Symbol2*)
A<int>::foo_template(int)
A<int>::foo_incorrect(Symbol*)
but incorrect mangling for A!Symbol:
A<Symbol*>::foo_correct(Symbol2*)
A<Symbol*>::foo_template(A<Symbol*>) <--- argument type wrong
A<Symbol*>::foo_incorrect(A<Symbol*>) <--- argument type wrong
Comment #1 by chatelet.guillaume — 2016-07-03T17:07:31Z
In C++, class types are not reference types. In D they are, and D represents the reference type as a pointer type when translating to C++.
The result is what you see, Symbol* instead of Symbol when looking at the C++ mangling.
This is working as intended.
Comment #4 by jbc.engelen — 2017-11-01T10:43:45Z
Read the bug report carefully before discarding it.
The argument type is currently "A<Symbol*>" (wrong), instead of "Symbol*"
Comment #5 by pro.mathias.lang — 2018-10-22T18:07:29Z
Marking as a duplicate of 16479, which is older, but for which there is a PR.
I just tried it with PR 8455 and it gets mangled correctly:
```
../../install/osx/bin/dmd -c lol.d; nm lol.o | c++filt
[...]
00000000000004c8 S A<int>::foo_template(int)
0000000000000040 S A<int>::foo_template(int) (.eh)
00000000000004d0 S A<int>::foo_incorrect(Symbol*)
0000000000000068 S A<int>::foo_incorrect(Symbol*) (.eh)
```
*** This issue has been marked as a duplicate of issue 16479 ***