While trying to rerun the gcov example supplied in "man gcov" it was noticed
that the branch values reported are incorrect.  The contents in tmp.c.gcov
appears to be correct.

gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1

#include <stdio.h>

int main (void)
{
  int i, total;

  total = 0;

  for (i = 0; i < 10; i++)
    total += i;

  if (total != 45)
    printf ("Failure\n");
  else
    printf ("Success\n");
  return 0;
}

fro...@frodak-laptop:~/gcov$ gcov -b tmp.c
File 'tmp.c'
Lines executed:87.50% of 8
Branches executed:100.00% of 4
Taken at least once:75.00% of 4
Calls executed:50.00% of 2
tmp.c:creating 'tmp.c.gcov'

fro...@frodak-laptop:~/gcov$ cat tmp.c.gcov
        -:    0:Source:tmp.c
        -:    0:Graph:tmp.gcno
        -:    0:Data:tmp.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:#include <stdio.h>
        -:    2:
function main called 1 returned 100% blocks executed 86%
        1:    3:int main (void)
        -:    4:{
        -:    5:  int i, total;
        -:    6:
        1:    7:  total = 0;
        -:    8:
       11:    9:  for (i = 0; i < 10; i++)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
       10:   10:    total += i;
        -:   11:
        1:   12:  if (total != 45)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:   13:    printf ("Failure\n");
call    0 never executed
        -:   14:  else
        1:   15:    printf ("Success\n");
call    0 returned 100%
        1:   16:  return 0;
        -:   17:}
        -:   18:


-- 
           Summary: gcov reports incorrect branches executed
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: frodak17 at gmail dot com


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

Reply via email to