[llvm-bugs] [Bug 50776] New: [LLVM-COV] The FALSE condition of "for" statement results in wrong coverage

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 20 01:56:10 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50776

            Bug ID: 50776
           Summary: [LLVM-COV] The FALSE condition of "for" statement
                    results in wrong coverage
           Product: Runtime Libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: cnwy1996 at outlook.com
                CC: llvm-bugs at lists.llvm.org

$ clang -v
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/wangyang/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

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

int main(void) {
  unsigned int a;
  unsigned char b;
  for (a = 0, b = 2; 
       a > b;
       a++) 
  {
    printf("Inloop: %d\n",a);
  }
  printf("Outloop: %d\n",a);
  return 0;
}

$ clang -w -O0 -g -fcoverage-mapping -fprofile-instr-generate=test.profraw
test.c; ./a.out; llvm-profdata merge test.profraw -o test.profdata; llvm-cov
show a.out -instr-profile=test.profdata test.c > test.lcov; cat test.lcov
Outloop: 0
    1|       |#include <stdlib.h>
    2|       |
    3|      1|int main(void) {
    4|      1|  unsigned int a;
    5|      1|  unsigned char b;
    6|      1|  for (a = 0, b = 2; 
    7|      1|       a > b;
    8|      1|       a++) 
    9|      0|  {
   10|      0|    printf("Inloop: %d\n",a);
   11|      0|  }
   12|      1|  printf("Outloop: %d\n",a);
   13|      1|  return 0;
   14|      1|}

Absolutely, line 8 was not executed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210620/b705c024/attachment-0001.html>


More information about the llvm-bugs mailing list