[llvm-bugs] [Bug 48409] New: [LLVM-COV] A blank statement after the continue statement is wrongly marked as executed in a while loop
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Dec 6 04:53:52 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48409
Bug ID: 48409
Summary: [LLVM-COV] A blank statement after the continue
statement is wrongly marked as executed in a while
loop
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: zhangxy_97 at 126.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: /usr/local/bin
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.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
$ cat main.c
#include <time.h>
#include <stdlib.h>
#include <stdbool.h>
bool is_predicate(int percent) {
int n = rand() % 100;
if (n < percent) {
return true;
}
return false;
}
int main(int argc,char *argv[]){
srand((unsigned)time(NULL));
while ( is_predicate(50) )
{
;
continue;
;
}
return 0;
}
$ clang -w -O0 -g -fcoverage-mapping -fprofle-instr-generate=main.profraw
main.c; ./a.out; llvm-profdata merge main.profraw -o main.profdata; llvm-cov
show a.out -instr-profile=main.profdata main.c > main.gcov; cat main.gcov
1| |#include <time.h>
2| |#include <stdlib.h>
3| |#include <stdbool.h>
4| 2|bool is_predicate(int percent) {
5| 2| int n = rand() % 100;
6| 2| if (n < percent) {
7| 1| return true;
8| 1| }
9| 1| return false;
10| 1|}
11| 1|int main(int argc,char *argv[]){
12| 1| srand((unsigned)time(NULL));
13| 2| while ( is_predicate(50) )
14| 1| {
15| 1| ;
16| 1| continue;
17| 1| ;
18| 0| }
19| 1|
20| 1| return 0;
21| 1|}
Line #17 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/20201206/c57b0c4a/attachment.html>
More information about the llvm-bugs
mailing list