public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/99444] New: [GCOV] Wrong coverage with "case" label in "switch" statement block
@ 2021-03-07  8:42 njuwy at smail dot nju.edu.cn
  2021-03-08  9:09 ` [Bug gcov-profile/99444] " marxin at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2021-03-07  8:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99444

            Bug ID: 99444
           Summary: [GCOV] Wrong coverage with "case" label in "switch"
                    statement block
           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: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure -enable-checking=release -enable-languages=c,c++
-disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC) 

$ cat test.c
int doit(int sel, int n, void *p) {
  int *const p0 = p;

  switch (sel) {
  case 0:
    do {
      *p0 += *p0;
    } while (--n);   
    return *p0 == 0; 
  default:
    __builtin_abort();
  }
}

int main() {
  int v0;
  v0 = 1;
  doit(0, 3, &v0);
  __builtin_exit(0);
}

$ gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov
File 'test.c'
Lines executed:84.62% of 13
Creating 'test.c.gcov'

        -:    0:Source:test.c
        -:    0:Graph:test.gcno
        -:    0:Data:test.gcda
        -:    0:Runs:1
        1:    1:int doit(int sel, int n, void *p) {
        1:    2:  int *const p0 = p;
        -:    3:
        1:    4:  switch (sel) {
        3:    5:  case 0:
        -:    6:    do {
        3:    7:      *p0 += *p0;
        3:    8:    } while (--n);   
        1:    9:    return *p0 == 0; 
    #####:   10:  default:
    #####:   11:    __builtin_abort();
        -:   12:  }
        -:   13:}
        -:   14:
        1:   15:int main() {
        -:   16:  int v0;
        1:   17:  v0 = 1;
        1:   18:  doit(0, 3, &v0);
        1:   19:  __builtin_exit(0);
        -:   20:}
        -:   21:

Line #5 should only be executed once.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug gcov-profile/99444] [GCOV] Wrong coverage with "case" label in "switch" statement block
  2021-03-07  8:42 [Bug gcov-profile/99444] New: [GCOV] Wrong coverage with "case" label in "switch" statement block njuwy at smail dot nju.edu.cn
@ 2021-03-08  9:09 ` marxin at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-03-08  9:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99444

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-03-08
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-08  9:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07  8:42 [Bug gcov-profile/99444] New: [GCOV] Wrong coverage with "case" label in "switch" statement block njuwy at smail dot nju.edu.cn
2021-03-08  9:09 ` [Bug gcov-profile/99444] " marxin at gcc dot gnu.org

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).