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

            Bug ID: 84758
           Summary: Wrong coverage for quite simple CFG
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Following isolated test-case is wrong:

$ cat gcovbug2.c
int x, y;

static void
foo (int a, int b)
{
  {
    if (a == 1 || a == 2)
      {
        x = 4;
        if (b == 3)
          x = 6;
      }
    else
      x = 15;
  }
}

int
main (void)
{
  foo (2, 3);
  return 0;
}

$ gcc --coverage gcovbug2.c && ./a.out && gcov gcovbug2.c && cat
gcovbug2.c.gcov
File 'gcovbug2.c'
Lines executed:90.00% of 10
Creating 'gcovbug2.c.gcov'

        -:    0:Source:gcovbug2.c
        -:    0:Graph:gcovbug2.gcno
        -:    0:Data:gcovbug2.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:int x, y;
        -:    2:
        -:    3:static void
        1:    4:foo (int a, int b)
        -:    5:{
        -:    6:  {
        1:    7:    if (a == 1 || a == 2)
        -:    8:      {
        1:    9:        x = 4;
        2:   10:        if (b == 3) <---- this line is wrong
        1:   11:          x = 6;
        -:   12:      }
        -:   13:    else
    #####:   14:      x = 15;
        -:   15:  }
        1:   16:}
        -:   17:
        -:   18:int
        1:   19:main (void)
        -:   20:{
        1:   21:  foo (2, 3);
        1:   22:  return 0;
        -:   23:}

Reply via email to