[Issue 16397] missing coverage from template instances when using separate compilation

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jul 9 06:20:59 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=16397

--- Comment #4 from Martin Nowak <code at dawg.eu> ---
Comment from Rainer
https://github.com/dlang/phobos/pull/5579#issuecomment-313905465

> Always generating coverage instrumentation of templated code will only work if > you cover all linked libraries, though. For example, coverage from druntime
> modules might leak into the report, just as well as that it might provide
> template instances without coverage instrumention.

Yes, but that's what we do with everything else as well, e.g. -unittest or
-profile, so it seems sensible to use this here as well.

That's also what C++ and gcov do.

----
cat > cova.cc << CODE
#include "covb.h"

int main()
{
    foo<int>(1, 2);
}
CODE
cat > covb.h << CODE
template <typename T>
T foo(T a, T b)
{
    return a + b;
}
CODE
g++ -fprofile-arcs -ftest-coverage cova.cc -o cova
./cova
gcov cova.cc
----
File 'covb.h'
Lines executed:100.00% of 2
Creating 'covb.h.gcov'

File 'cova.cc'
Lines executed:100.00% of 3
Creating 'cova.cc.gcov'
----

--


More information about the Digitalmars-d-bugs mailing list