Bug 10249 – incorrect mangling for overloaded symbol
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-02T23:57:00Z
Last change time
2013-06-24T23:16:05Z
Keywords
pull, rejects-valid, wrong-code
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2013-06-02T23:57:16Z
If a template takes alias parameter, X1 to X3 should be different instances each other, but does not.
template X(alias f) {}
class C
{
void foo(int) {}
void foo(string) {}
}
alias X1 = X!(C.foo);
alias X2 = X!(__traits(getOverloads, C, "foo")[0]);
alias X3 = X!(__traits(getOverloads, C, "foo")[1]);
static assert(!__traits(isSame, X1, X2)); // fails, should pass
static assert(!__traits(isSame, X2, X3)); // pass
static assert(!__traits(isSame, X1, X3)); // pass
// Even more worse, mangled name of each instances is incorrect.
pragma(msg, X1.mangleof); // 4test27__T1XS18_D4test1C3fooMFiZvZ
pragma(msg, X2.mangleof); // 4test27__T1XS18_D4test1C3fooMFiZvZ
pragma(msg, X3.mangleof); // 4test29__T1XS20_D4test1C3fooMFAyaZvZ
Currently X1 and X2 has same mangled name. If template X has actual code, the instantiated code symbols would conflict at the link stage.