This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gcov-profile/85294] [GCOV] A "if(0) break;" statement is wrongly marked as executed when they are nested in for(;;) statement and prefixed with an struct declaration and followed by "if(1) break;" statement in gcov


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

--- Comment #1 from Yibiao Yang <yangyibiao at nju dot edu.cn> ---
1. when removing Line #7 and Line #8, the result is correct. 
2. when removing Line #4, the result is also correct. 


Besides, there is an existing bug 85274 is similar to the current bug. Bug
85274 is copyed as follows. It is unclear whether this one is a duplication of
bug 85274.  

$ cat small.c
struct s {int s1;};
int a = 0;
int main() {
  for (; 1;) {
    struct s g;
    if (0)
      return 2;
    return 0;
    a = 0;
  }
  return 0;
}

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

        -:    0:Source:small.c
        -:    0:Graph:small.gcno
        -:    0:Data:small.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:struct s {int s1;};
        -:    2:int a = 0;
        1:    3:int main() {
        1:    4:  for (; 1;) {
        -:    5:    struct s g;
        -:    6:    if (0)
        1:    7:      return 2;
        1:    8:    return 0;
        -:    9:    a = 0;
        -:   10:  }
    #####:   11:  return 0;
        -:   12:}

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]