Comment #0 by leandro.lucarella — 2012-05-03T03:31:28Z
+++ This issue was initially created as a clone of Issue #8016 +++
This looks like a reincarnation of bug 7745, but is different.
Testcase:
m1.d
---
module m1;
import m2;
private void t(alias Code)()
{
return Code();
}
void f()
{
t!( () { } )();
}
---
m2.d
---
module m2;
import m1;
---
dmd -c -inline -release -g m2.d && nm m2.o | grep '_D2m11fFZv$'
00000000 T _D2m11fFZv
Which means that _D2m11fFZv (AKA m1.f()) is included in the text
(code) section of m2.o, but it shouldn't, it should only be in m1.d (which I
didn't even compile), otherwise when linking both m1.o and m2.o you'll get a
"multiple definition" error. Symbol _D2m11fFZv should be not present at all in that object file.
Please note that the compiler flags -inline -release has to be used to
reproduce the bug, removing either makes it go away. -O is irrelevant.
Confirmed in both 32 and 64 bits.
This regression was introduced by commit "fix Issue 2962 - ICE(glue.c) or bad
codegen passing variable as template value parameter":
D1: https://github.com/D-Programming-Language/dmd/commit/d5a33a1
This pull request (for D2, expect a small conflict when merging), fixes the problem:
https://github.com/D-Programming-Language/dmd/pull/920
Comment #1 by leandro.lucarella — 2012-05-03T04:22:06Z
Add a test case for this bug. Even when is not reproducible in D2 right now, maybe is a good idea to have the test case anyway so it doesn't fail in the future as D1 does now.
https://github.com/D-Programming-Language/dmd/pull/922
This includes also this test case, which is also a regression and it's fixed by the pull request. This testcase doesn't need -inline -release to be reproduced though!
m1.d
---
module m1;
import m2;
private void t(alias Code)()
{
return Code();
}
void f()
{
t!( () { } )();
}
bool forceSemantic()
{
f();
return true;
}
static assert(forceSemantic());
---
m2.d
---
module m2;
import m1;
---
Comment #2 by github-bugzilla — 2012-05-03T13:27:36Z