Comment #0 by snarwin+bugzilla — 2023-08-23T01:25:38Z
Example program:
--- test.d
extern(C++)
struct S
{
void fun(T)(T t) {}
alias fun_int = fun!int;
}
--- main.cpp
struct S
{
template<typename T>
void fun(T t);
};
int main()
{
S s;
s.fun<int>(0);
return 0;
}
---
When compiling test.d with DMD 2.104.0 and main.cpp with either gcc or clang, the resulting program fails to link. The cause is inconsistent mangling of the member function S::fun<int>.
---
$ nm main.o test.o | grep fun
U _ZN1S3funIiEEvT_
0000000000000000 W _ZN1S3funIiEEvi
---
GCC and clang correctly mangle the parameter type of S::fun<int> as `T_` (first template argument), but DMD incorrectly mangles it as `i` (int).
Comment #1 by snarwin+bugzilla — 2023-08-23T01:28:05Z
Also affects LDC 1.33.0.
Comment #2 by robert.schadek — 2024-12-13T19:30:35Z