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

            Bug ID: 101418
           Summary: [Gcov] there is the executed line code in dead code
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: byone.heng at gmail dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$./gcc -v                                                                       
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=/home/x/project/gcc/build/install/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/x/project/gcc/build/install
--enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20210105 (experimental) (GCC)

$cat test.c
——————————————————————————

static volatile long int true_var = 1;
long int false_var = 0;

void __attribute__((noinline,noipa))
foo(int id)
{
  if( false_var > 0 )
  {
  switch (id)
    {
    case (-__INT_MAX__ - 1)...-1:
      __builtin_abort ();
    default:;
    }
  }
  switch (id)
    {
    case (-__INT_MAX__ - 1)...-1:
      __builtin_abort ();
    default:;
    }
}

int main()
{
  foo(1);
  return 0;
}


——————————————————————————


$gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov

        -:    3:static volatile long int true_var = 1;
        -:    4:long int false_var = 0;
        -:    5:
        -:    6:void __attribute__((noinline,noipa))
        1:    7:foo(int id)
        -:    8:{
        1:    9:  if( false_var > 0 )
        -:   10:  {
    #####:   11:  switch (id)
        -:   12:    {
    #####:   13:    case (-__INT_MAX__ - 1)...-1:
    #####:   14:      __builtin_abort ();
        1:   15:    default:;
        -:   16:    }
        -:   17:  }
        1:   18:  switch (id)
        -:   19:    {
    #####:   20:    case (-__INT_MAX__ - 1)...-1:
    #####:   21:      __builtin_abort ();
        1:   22:    default:;
        -:   23:    }
        1:   24:}
        -:   25:
        1:   26:int main()
        -:   27:{
        1:   28:  foo(1);
        1:   29:  return 0;
        -:   30:}


Line 15 should not be executed.

Reply via email to