https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42015

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Ok, after code inspection, I came to observation that the output is correct.
Let's assume following example:

$ cat pr42015.c.gcov
        -:    0:Source:pr42015.c
        -:    0:Graph:pr42015.gcno
        -:    0:Data:pr42015.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:#include <stdio.h>
        -:    2:
        1:    3:int main (void)
        -:    4:{
        -:    5:  int i, total;
        -:    6:
        1:    7:  total = 0;
        -:    8:
       11:    9:  for (i = 0; i < 10; i++)
       10:   10:    total += i;
        -:   11:
        1:   12:  if (total != 1111)
        1:   13:    return 0;
        -:   14:
    #####:   15:  if (total != 45)
    #####:   16:    printf ("Failure\n");
        -:   17:  else
    #####:   18:    printf ("Success\n");
    #####:   19:  return 0;
        -:   20:}

$ gcov pr42015.c -b
File 'pr42015.c'
Lines executed:60.00% of 10
Branches executed:66.67% of 6
Taken at least once:50.00% of 6
Calls executed:0.00% of 2
Creating 'pr42015.c.gcov'

'Branches executed' means a number of branches whose condition was at least
once evaluated (and obviously one branch is taken).
Thus, as the condition on line 15 is never executed we have 2 branches that
were not executed. On the other hand, 'Taken at least once'
equal to 3 means execution of both branches of 'for' statement and 1 for 'if'
on the line 12.

Hope it's now clear, closing the PR as invalid.

Reply via email to