[Issue 16397] test_runner in coverage mode doesn't match with individual test (covers less)
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jul 8 11:04:56 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=16397
Martin Nowak <code at dawg.eu> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |code at dawg.eu
--- Comment #1 from Martin Nowak <code at dawg.eu> ---
Turns out to be a rather trivial but inherent problem of how coverage and
linkers work.
If a template methods is instantiated in two separately compiled modules (say
std.digest.crc and std.digest.digest) the definition from the first object in
the linker argument order is picked.
Here we have our problem std.digest.digest instantiates WrapperDigest!CRC which
gets emitted with coverage information, but std.digest.crc also instantiates
WrapperDigest!CRC without coverage information (since it's in a foreign module)
the one that gets picked is the latter.
Just like with any other template behavior and -unittest I think dmd should
always emit coverage instrumentation, even if it's for functions in foreign
modules, since eventually any instance might get picked.
This requires to mangle __bcoverage and __coverage and make them linkable from
other modules, at the moment they are private symbols, only accessible from
within a single object file.
The logic that prevents increments of "foreign" modules is here in dmd.
https://github.com/dlang/dmd/blob/ce96c01d271f914cd9acb6100f7fa9f4d494ee8c/src/ddmd/toir.d#L67
--
More information about the Digitalmars-d-bugs
mailing list