<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] "abort" function leads to incorrect coverage"
href="https://bugs.llvm.org/show_bug.cgi?id=49440">49440</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LLVM-COV] "abort" function leads to incorrect coverage
</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>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>cnwy1996@outlook.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: /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 <limits.h>
#include <stdio.h>
extern void abort(void);
#if INT_MAX == 32767
#define LONG_CHARCONST '!\234a'
#define SHORT_CHARCONST '\234a'
#define POS_CHARCONST '\1'
#elif INT_MAX == 2147483647
#define LONG_CHARCONST '!\234abc'
#define SHORT_CHARCONST '\234abc'
#define POS_CHARCONST '\234a'
#elif INT_MAX == 9223372036854775807
#define LONG_CHARCONST '!\234abcdefg'
#define SHORT_CHARCONST '\234abcdefg'
#define POS_CHARCONST '\234a'
#else
#define LONG_CHARCONST '\234a'
#define SHORT_CHARCONST '\234a'
#define POS_CHARCONST '\1'
#endif
#if POS_CHARCONST < 0
#error Charconst incorrectly sign-extended
#endif
#if LONG_CHARCONST != SHORT_CHARCONST
#error Overly long charconst truncates wrongly for preprocessor
#endif
int main() {
if (LONG_CHARCONST != SHORT_CHARCONST){
abort();
}
if (LONG_CHARCONST != SHORT_CHARCONST)
abort();
if (POS_CHARCONST < 0)
abort();
printf("passed\n");
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
passed
1| |#include <limits.h>
2| |#include <stdio.h>
3| |extern void abort(void);
4| |
5| |#if INT_MAX == 32767
6| |#define LONG_CHARCONST '!\234a'
7| |#define SHORT_CHARCONST '\234a'
8| |#define POS_CHARCONST '\1'
9| |#elif INT_MAX == 2147483647
10| 2|#define LONG_CHARCONST '!\234abc'
11| 2|#define SHORT_CHARCONST '\234abc'
12| 1|#define POS_CHARCONST '\234a'
13| |#elif INT_MAX == 9223372036854775807
14| |#define LONG_CHARCONST '!\234abcdefg'
15| |#define SHORT_CHARCONST '\234abcdefg'
16| |#define POS_CHARCONST '\234a'
17| |#else
18| |
19| |#define LONG_CHARCONST '\234a'
20| |#define SHORT_CHARCONST '\234a'
21| |#define POS_CHARCONST '\1'
22| |#endif
23| |
24| |#if POS_CHARCONST < 0
25| |#error Charconst incorrectly sign-extended
26| |#endif
27| |
28| |#if LONG_CHARCONST != SHORT_CHARCONST
29| |#error Overly long charconst truncates wrongly for preprocessor
30| |#endif
31| |
32| 1|int main() {
33| 1| if (LONG_CHARCONST != SHORT_CHARCONST){
34| 0| abort();
35| 0| }
36| 1| if (LONG_CHARCONST != SHORT_CHARCONST)
37| 1| abort();
38| 1| if (POS_CHARCONST < 0)
39| 0| abort();
40| 1| printf("passed\n");
41| 1| return 0;
42| 1|}
In my opinion, line #34, #37 and #39 should not be 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>