[llvm-bugs] [Bug 37092] New: [LLVM-COV] Wrong coverage with comparison for a malloced memory address and NULL
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 11 10:22:56 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37092
Bug ID: 37092
Summary: [LLVM-COV] Wrong coverage with comparison for a
malloced memory address and NULL
Product: Runtime Libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: libprofile library
Assignee: unassignedbugs at nondot.org
Reporter: yangyibiao at nju.edu.cn
CC: llvm-bugs at lists.llvm.org
$ clang -v
clang version 7.0.0- (trunk)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8.0.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8.0.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8.0.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
$ cat small.c
#include <stdlib.h>
int main (void)
{
static int *p;
p = malloc (sizeof (int));
if (p == NULL)
return 0;
*p = 7;
return 1;
}
$ clang -O0 -g -fcoverage-mapping -fprofile-instr-generate=small.profraw
small.c; ./a.out; llvm-profdata merge small.profraw -o small.profdata; llvm-cov
show a.out -instr-profile=small.profdata small.c > small.gcov; cat small.gcov
1| |#include <stdlib.h>
2| |
3| |int main (void)
4| 1|{
5| 1| static int *p;
6| 1|
7| 1| p = malloc (sizeof (int));
8| 1| if (p == NULL)
9| 1| return 0;
10| 1|
11| 1| *p = 7;
12| 1| return 1;
13| 1|}
Line #9 is wrongly marked as 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/20180411/e8f6794d/attachment.html>
More information about the llvm-bugs
mailing list