public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/101552] New: [GCOV] Wrong coverage with "for( )" statement
@ 2021-07-21 12:46 njuwy at smail dot nju.edu.cn
2021-07-21 13:06 ` [Bug gcov-profile/101552] [GCOV] Wrong coverage with "for( )" and setjmp njuwy at smail dot nju.edu.cn
0 siblings, 1 reply; 2+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2021-07-21 12:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101552
Bug ID: 101552
Summary: [GCOV] Wrong coverage with "for( )" statement
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: njuwy at smail dot nju.edu.cn
CC: marxin at gcc dot gnu.org
Target Milestone: ---
$ 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
extern int strcmp(const char *, const char *);
extern char *strcpy(char *, const char *);
extern void abort(void);
extern void exit(int);
void *buf[20];
void __attribute__((noinline)) sub2(void) { __builtin_longjmp(buf, 1); }
int main() {
char *p = (char *)__builtin_alloca(20);
strcpy(p, "test");
if (__builtin_setjmp(buf)) {
if (strcmp(p, "test") != 0)
abort();
exit(0);
}
{
int *q = (int *)__builtin_alloca(p[2] * sizeof(int));
printf("Excuted!\n");
int i;
for (i = 0; i < p[2]; i++)
q[i] = 0;
while (1)
sub2();
}
}
$ 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
Excuted!
1| |#include<stdio.h>
2| |extern int strcmp(const char *, const char *);
3| |extern char *strcpy(char *, const char *);
4| |extern void abort(void);
5| |extern void exit(int);
6| |
7| |void *buf[20];
8| |
9| 1|void __attribute__((noinline)) sub2(void) {
__builtin_longjmp(buf, 1); }
10| |
11| 1|int main() {
12| 1| char *p = (char *)__builtin_alloca(20);
13| 1|
14| 1| strcpy(p, "test");
15| 1|
16| 1| if (__builtin_setjmp(buf)) {
17| 1| if (strcmp(p, "test") != 0)
18| 0| abort();
19| 1|
20| 1| exit(0);
21| 1| }
22| 0|
23| 0| {
24| 0| int *q = (int *)__builtin_alloca(p[2] * sizeof(int));
25| 0| printf("Excuted!\n");
26| 0| int i;
27| 0|
28| 115| for (i = 0; i < p[2]; i++)
29| 115| q[i] = 0;
30| 0|
31| 1| while (1)
32| 1| sub2();
33| 0| }
34| 0|}
line 16 was executed twice, line 24 to 26 was executed once and line 28 was
executed 116 times.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug gcov-profile/101552] [GCOV] Wrong coverage with "for( )" and setjmp
2021-07-21 12:46 [Bug gcov-profile/101552] New: [GCOV] Wrong coverage with "for( )" statement njuwy at smail dot nju.edu.cn
@ 2021-07-21 13:06 ` njuwy at smail dot nju.edu.cn
0 siblings, 0 replies; 2+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2021-07-21 13:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101552
Yang Wang <njuwy at smail dot nju.edu.cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Yang Wang <njuwy at smail dot nju.edu.cn> ---
Sorry, I entered the wrong website...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-21 13:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 12:46 [Bug gcov-profile/101552] New: [GCOV] Wrong coverage with "for( )" statement njuwy at smail dot nju.edu.cn
2021-07-21 13:06 ` [Bug gcov-profile/101552] [GCOV] Wrong coverage with "for( )" and setjmp njuwy at smail dot nju.edu.cn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).