https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97921
Bug ID: 97921 Summary: [GCOV]inline function with an incremental argument lead to incorrect coverage Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: yangyibiao at outlook dot com CC: marxin at gcc dot gnu.org Target Milestone: --- $ cat test.c int v = 8; __attribute__ ((noinline)) int foo(int x, ...) { return 0; } extern inline __attribute__ ((always_inline, gnu_inline)) int bar(int x, ...) { return foo(x); } int main() { if (bar(0, ++v) != 0) return 1; return 0; } $ gcc -O0 --coverage test.c; ./a.out; gcov test.c; cat test.c.gcov File 'test.c' Lines executed:85.71% of 7 Creating 'test.c.gcov' -: 0:Source:test.c -: 0:Graph:test.gcno -: 0:Data:test.gcda -: 0:Runs:1 -: 1:int v = 8; -: 2: -: 3:__attribute__ ((noinline)) 1: 4:int foo(int x, ...) 1: 5:{ return 0; } -: 6: -: 7:extern inline __attribute__ ((always_inline, gnu_inline)) -: 8:int bar(int x, ...) -: 9:{ 1: 10: return foo(x); -: 11:} -: 12: 1: 13:int main() -: 14:{ 2: 15: if (bar(0, ++v) != 0) #####: 16: return 1; 1: 17: return 0; -: 18:} ########################## Line 15 is wrongly marked as executed 2 times. When debug it in debugger and set breakpoint at Line 15, it only hit once. $ gcc --version; gcov --version gcc (GCC) 10.0.1 20200419 (experimental) Copyright (C) 2020 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. gcov (GCC) 10.0.1 20200419 (experimental) Copyright (C) 2020 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.