[Issue 16397] missing coverage from template instances when using separate compilation
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jul 8 11:20:12 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=16397
--- Comment #2 from Martin Nowak <code at dawg.eu> ---
cat > a.d << CODE
module a;
import b;
unittest
{
foo!int();
}
CODE
cat > b.d << CODE
module b;
void foo(T)()
{
return; // line is covered
}
unittest
{
foo!int();
}
CODE
dmd -c -cov -unittest a.d
dmd -c -cov -unittest b.d
dmd -main a.o b.o -ofbug
./bug
cat a.lst b.lst
----
|module a;
|import b;
|
|unittest
|{
1| foo!int();
|}
a.d is 100% covered
|module b;
|
|void foo(T)()
|{
0000000| return; // line is covered
|}
|
|unittest
|{
1| foo!int();
|}
b.d is 50% covered
----
With different linker order, both calls use the foo instantiation with coverage
instrumentation.
dmd -main b.o a.o -ofbug
./bug
cat a.lst b.lst
----
|module a;
|import b;
|
|unittest
|{
1| foo!int();
|}
a.d is 100% covered
|module b;
|
|void foo(T)()
|{
2| return; // line is covered
|}
|
|unittest
|{
1| foo!int();
|}
b.d is 100% covered
➜ D cat a.lst b.lst
20:18:21
|module a;
|import b;
|
|unittest
|{
1| foo!int();
|}
a.d is 100% covered
|module b;
|
|void foo(T)()
|{
2| return; // line is covered
|}
|
|unittest
|{
1| foo!int();
|}
b.d is 100% covered
----
--
More information about the Digitalmars-d-bugs
mailing list