Bug 85273 - [GCOV] return statement in else block of if(1) statement when there is an array declaration statement and a goto statement in gcov
Summary: [GCOV] return statement in else block of if(1) statement when there is an arr...
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 9.0
Assignee: Martin Liška
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-07 06:12 UTC by Anonymous
Modified: 2018-07-24 13:29 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-04-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anonymous 2018-04-07 06:12:14 UTC
$ cat small.c
int main() {
b:
  {
    int c[1];
    if (1)
      ;
    else
      return 0;
    return 0;
    goto b;
  }
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 4
Creating 'small.c.gcov'

        -:    0:Source:small.c
        -:    0:Graph:small.gcno
        -:    0:Data:small.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        1:    1:int main() {
        1:    2:b:
        -:    3:  {
        -:    4:    int c[1];
        -:    5:    if (1)
        -:    6:      ;
        -:    7:    else
        1:    8:      return 0;
        1:    9:    return 0;
        -:   10:    goto b;
        -:   11:  }
        -:   12:}

**********
Line #8 is wrongly marked as executed.

While removing any of Line #4 or Line #10, the result is correct.
Comment 1 Martin Liška 2018-07-24 13:29:28 UTC
CFG is following:

main ()
{
  int c[1];
  int D.1905;
  int _1;

  <bb 2> :
b:

  <bb 3> :
  _1 = 0;
  c ={v} {CLOBBER};

  <bb 4> :
<L6>:
  return _1;

}

so again it's folded away.