<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 - wrong coverage for struct pointer array assignment"
href="https://bugs.llvm.org/show_bug.cgi?id=45821">45821</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>wrong coverage for struct pointer array assignment
</td>
</tr>
<tr>
<th>Product</th>
<td>Runtime Libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>normal
</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>yangyibiao@hust.edu.cn
</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 (/home/yibiao/.cache/yay/llvm-git/llvm-project
871beba234a83a2a02da9dedbd59b91a1bfbd7af)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ clang -O0 -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.c.lcov; cat small.c.lcov
1| |#include <setjmp.h>
2| |#include <stdlib.h>
3| |
4| |jmp_buf buf;
5| |struct S { const int f; } g;
6| |
7| 1|void foo(void) { longjmp(buf, 1); }
8| |
9| 1|int main () {
10| 1| if(setjmp(buf)) {
11| 1| return 0;
12| 1| }
13| 0| struct S * const sa[2] = {&g, &g};
14| 1| while (1) foo();
15| 0|}
*****
Line #13 is wrongly marked as not executed. In fact, this line should be
executed. When setting breakpoint for line 13, lldb reaches this line as
follow:
$ clang -g small.c; lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/a.out' (x86_64).
(lldb) b 13
Breakpoint 1: where = a.out`main + 47 at small.c:13:20, address =
0x000000000040118f
(lldb) run
Process 87671 launched: '/home/yibiao/a.out' (x86_64)
Process 87671 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x000000000040118f a.out`main at small.c:13:20
10 if(setjmp(buf)) {
11 return 0;
12 }
-> 13 struct S * const sa[2] = {&g, &g};
14 while (1) foo();
15 }
(lldb)
$ cat small.c
#include <setjmp.h>
#include <stdlib.h>
jmp_buf buf;
struct S { const int f; } g;
void foo(void) { longjmp(buf, 1); }
int main () {
if(setjmp(buf)) {
return 0;
}
struct S * const sa[2] = {&g, &g};
while (1) foo();
}</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>