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

            Bug ID: 101147
           Summary: [GCOV] Wrong coverage with label inside "while" loop
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: njuwy at smail dot nju.edu.cn
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure -enable-checking=release -enable-languages=c,c++
-disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC) 

$ cat test.c
#include <stdlib.h>
#include<stdio.h>

int x;
int main() {
  int i = 0;
  x = 0;
  if (x) {
    for (; i < 10; ++i) {
    doit:
      x = i;
    }
  }
  if (!x)
    goto doit;
  if (x != 9)
    __builtin_abort();
  return 0;
}

$ gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov
libgcov profiling error:/home/wangyang/coverage/test/test.gcda:overwriting an
existing profile data with a different timestamp
File 'test.c'
Lines executed:91.67% of 12
Creating 'test.c.gcov'

        -:    0:Source:test.c
        -:    0:Graph:test.gcno
        -:    0:Data:test.gcda
        -:    0:Runs:1
        -:    1:#include <stdlib.h>
        -:    2:#include<stdio.h>
        -:    3:
        -:    4:int x;
        1:    5:int main() {
        1:    6:  int i = 0;
        1:    7:  x = 0;
        1:    8:  if (x) {
      10*:    9:    for (; i < 10; ++i) {
        9:   10:    doit:
       10:   11:      x = i;
        -:   12:    }
        -:   13:  }
        2:   14:  if (!x)
        1:   15:    goto doit;
        1:   16:  if (x != 9)
    #####:   17:    __builtin_abort();
        1:   18:  return 0;
        -:   19:}

Coverage of line 9 should be same as line 10
  • [Bug gcov-profile/101147] New: ... njuwy at smail dot nju.edu.cn via Gcc-bugs

Reply via email to