Thread overview
[Issue 5848] New: Coverage always report 0000000 for inlined function
Apr 16, 2011
kennytm@gmail.com
Apr 16, 2011
kennytm@gmail.com
Apr 17, 2011
kennytm@gmail.com
Apr 23, 2012
SomeDude
Apr 23, 2012
kennytm@gmail.com
Apr 23, 2012
SomeDude
April 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5848

           Summary: Coverage always report 0000000 for inlined function
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: kennytm@gmail.com


--- Comment #0 from kennytm@gmail.com 2011-04-16 11:39:31 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5848


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2011-04-16 11:50:22 PDT ---
What kind of textual output do you desire in this situation?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5848



--- Comment #2 from kennytm@gmail.com 2011-04-16 12:06:15 PDT ---
(In reply to comment #1)
> What kind of textual output do you desire in this situation?

What do you mean?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5848



--- Comment #3 from bearophile_hugs@eml.cc 2011-04-16 12:54:22 PDT ---
(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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 17, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5848



--- Comment #4 from kennytm@gmail.com 2011-04-17 00:50:20 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5848


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #5 from SomeDude <lovelydear@mailmetrash.com> 2012-04-23 09:09:59 PDT ---
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>

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5848



--- Comment #6 from kennytm@gmail.com 2012-04-23 09:44:00 PDT ---
(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'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5848



--- Comment #7 from SomeDude <lovelydear@mailmetrash.com> 2012-04-23 12:29:55 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------