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

            Bug ID: 93735
           Summary: [GCOV] incorrect coverage for calling variable
                    arguments function with incremental expression in its
                    parameter list
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yangyibiao at hust dot edu.cn
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcov -v
gcov (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.


$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-shared
--enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-lto --enable-plugin --enable-install-libiberty
--with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib
--disable-werror --enable-checking=release --enable-default-pie
--enable-default-ssp --enable-cet=auto gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
gcc version 9.2.0 (GCC)

$ cat small.c
int v = 8;

__attribute__((noinline)) int foo(int x, int y, ...) { return x; }

inline __attribute__((always_inline, gnu_inline)) int bar(int x, ...) { return
foo(x, 1, 2); }

int main(void)
{
  bar(0, ++v, 1);
  if (bar(0, ++v, 1) != 0)
    return 1;
  return 0;
}


$ gcc -O0 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:71.43% of 7
Creating 'small.c.gcov'

    -:    0:Source:small.c
    -:    0:Graph:small.gcno
    -:    0:Data:small.gcda
    -:    0:Runs:1
    -:    1:int v = 8;
    -:    2:
    2:    3:__attribute__((noinline)) int foo(int x, int y, ...) { return x; }
    -:    4:
#####:    5:inline __attribute__((always_inline, gnu_inline)) int bar(int x,
...) { return foo(x, 1, 2); }
    -:    6:
    1:    7:int main(void)
    -:    8:{
    1:    9:  bar(0, ++v, 1);
    2:   10:  if (bar(0, ++v, 1) != 0)
#####:   11:    return 1;
    1:   12:  return 0;
    -:   13:}


################################################################################
### We can find that: Line #9 is marked as executed one time. 
### However, Line #10 is wrongly marked as executed two times. 
### when removing ++v in its parameter list, the coverage will be correct. 
################################################################################

Reply via email to