some details regarding the bug:
previously, dmd happily creates .o file, and then linker complains about duplicate definition. and now, i have no way to know *what* symbol was defined multiple times.
so this is not about "compiler doesn't check for two `foo()`s", it's about compiler ICEing now, and i have no way to know which symbol i redefined.
Comment #2 by b2.temp — 2017-04-26T13:05:03Z
x86-64 seems to be affected too but in a different way. The example provided previously compiles and links, instead of complaining about double definition.
Comment #3 by code — 2017-04-28T09:59:31Z
That goes on me I think, you've just found another way to emit 2 different functions with identical mangling.
https://github.com/dlang/dmd/pull/6719, fix for Issue 17339
This should be an error in the frontend already, b/c the 2 foos aren't overrideable.
Comment #4 by ketmar — 2017-04-28T10:18:19Z
yeah. but the frontend will check for conflicting overloads only when `foo()` will be called. i guess this was done to gain some compilation speed by not checking each symbol against other symbols (O(n^2), i think).
but this can be done differently, by using a hash table of all emited mangled names. this should be amortized O(n), and virtually painless.
i mean, yes, the frontend should check for conflicting overloads even if they weren't called anywhere.
Comment #5 by code — 2017-05-31T23:10:37Z
(In reply to Ketmar Dark from comment #4)
> i mean, yes, the frontend should check for conflicting overloads even if
> they weren't called anywhere.
Could be easily checked in overloadInsert et.al.
Comment #6 by code — 2017-06-29T01:25:31Z
cat > bug.d << CODE
void bug(Args...)()
{
}
void test(bool coin)
{
if (coin)
{
string foobar;
bug!foobar();
}
else
{
string foobar;
bug!foobar();
}
}
CODE
----
dmd -c bug.d
----
Internal error: ddmd/backend/elfobj.c 1739
----
This is a real instance of this bug caused by ambiguous mangling of local variables (see issue 14831).
Interestingly enough `void bug(alias var)()` only outputs a single template instance :o.
Comment #7 by github-bugzilla — 2017-07-01T21:07:45Z