digitalmars.D.bugs - [Issue 11619] New: dmd -cov doesn't work correctly with template functions and separate compilation
- d-bugmail puremagic.com (69/69) Nov 27 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11619
https://d.puremagic.com/issues/show_bug.cgi?id=11619 Summary: dmd -cov doesn't work correctly with template functions and separate compilation Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: hsteoh quickfur.ath.cx CODE: -----mod.d----- import std.stdio; void func(T)(T t) { writeln("HELLO"); } unittest { func(0); } --------------- -----main.d---- import mod; void main() { func(0); } --------------- Compilation: --------- dmd -unittest -cov -c main.d dmd -unittest -cov -c mod.d dmd -ofmain main.o mod.o --------- Program output: ------- HELLO HELLO ------- Contents of mod.lst after running the program: ------- |import std.stdio; | |void func(T)(T t) { 0000000| writeln("HELLO"); |} |unittest { 1| func(0); |} mod.d is 50% covered ------- Notice that the line func(0) has a count of 1, yet the body of func has a count of zero! (Not to mention the fact that main() calls func a second time, thus the correct count should be 2.) Commenting out the call to func in main() makes the problem go away. Commenting out the call to func in the unittest, instead, makes both coverage counts disappear (another related bug?) from mod.lst. Compiling both source files at the same time (dmd -cov -unittest main.d mod.d) makes the problem go away. Turning func into a non-template function also makes the problem go away. So it appears that the bug is triggered by a combination of separate compilation and template functions, possibly involving unittests. I'm submitting this bug as a major issue, because it makes coverage numbers unreliable, thus breaking the whole point of -cov in a major way. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 27 2013