<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [LLVM-COV] A blank statement after the continue statement is wrongly marked as executed in a while loop"
href="https://bugs.llvm.org/show_bug.cgi?id=48409">48409</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LLVM-COV] A blank statement after the continue statement is wrongly marked as executed in a while loop
</td>
</tr>
<tr>
<th>Product</th>
<td>Runtime Libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>libprofile library
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zhangxy_97@126.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>$ 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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>