Bug 5848 – Coverage always report 0000000 for inlined function

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-04-16T11:39:31Z
Last change time
2024-12-13T17:55:08Z
Assigned to
No Owner
Creator
kennytm
Moved to GitHub: dmd#18337 →

Comments

Comment #0 by kennytm — 2011-04-16T11:39:31Z
When a function is inlined, the coverage result will not consider it was called, and always report the coverage count as 0000000. For example, the program: int inlined(int p, int q) { return p+q; } void main() { inlined(1, 3); } without -inline, the coverage result is |int inlined(int p, int q) { 1| return p+q; |} |void main() { 1| inlined(1, 3); |} x.d is 100% covered with -inline, the 'inlined' function becomes uncovered |int inlined(int p, int q) { 0000000| return p+q; |} |void main() { 1| inlined(1, 3); |} x.d is 50% covered
Comment #1 by bearophile_hugs — 2011-04-16T11:50:22Z
What kind of textual output do you desire in this situation?
Comment #2 by kennytm — 2011-04-16T12:06:15Z
(In reply to comment #1) > What kind of textual output do you desire in this situation? What do you mean?
Comment #3 by bearophile_hugs — 2011-04-16T12:54:22Z
(In reply to comment #2) > (In reply to comment #1) > > What kind of textual output do you desire in this situation? > > What do you mean? What coverage results textual file do you want DMD to save on disk about that inlined() function when you compile the program with the -inline switch too?
Comment #4 by kennytm — 2011-04-17T00:50:20Z
(In reply to comment #3) > (In reply to comment #2) > > (In reply to comment #1) > > > What kind of textual output do you desire in this situation? > > > > What do you mean? > > What coverage results textual file do you want DMD to save on disk about that > inlined() function when you compile the program with the -inline switch too? Ideally that line should display "1", like the 2nd piece of code I've shown in the first post. The coverage percent should be 100%, not 50%. Why would one expect to get 0000000 when a line of code is used? If it's not possible to get an exact count, at least it should show something other than 0000000, and count that line as covered. In gcov the equivalent program shows '1' in the corresponding line even with maximum optimization (-O3). So avoiding 0000000 in most of the cases should be possible.
Comment #5 by lovelydear — 2012-04-23T09:09:59Z
With dmd 2.059: PS E:\DigitalMars\dmd2\samples> rdmd -cov bug PS E:\DigitalMars\dmd2\samples> cat bug.lst |//import std.stdio, std.range, std.algorithm, std.string; | |import std.stdio; | |int inlined(int p, int q) { 1| return p+q; |} |void main() { 1| inlined(1, 3); |} bug.d is 100% covered PS E:\DigitalMars\dmd2\samples>
Comment #6 by kennytm — 2012-04-23T09:44:00Z
(In reply to comment #5) > With dmd 2.059: > > PS E:\DigitalMars\dmd2\samples> rdmd -cov bug > PS E:\DigitalMars\dmd2\samples> cat bug.lst > |//import std.stdio, std.range, std.algorithm, std.string; > | > |import std.stdio; > | > |int inlined(int p, int q) { > 1| return p+q; > |} > |void main() { > 1| inlined(1, 3); > |} > bug.d is 100% covered > PS E:\DigitalMars\dmd2\samples> Please make sure you have the '-inline' flag. Test with 'dmd', not 'rdmd'.
Comment #7 by lovelydear — 2012-04-23T12:29:55Z
(In reply to comment #6) > (In reply to comment #5) > Please make sure you have the '-inline' flag. Test with 'dmd', not 'rdmd'. OK, with -inline I get the same result you got.
Comment #8 by robert.schadek — 2024-12-13T17:55:08Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18337 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB