[Bug gcov-profile/93766] New: [GCOV] incorrect coverage when compiled with option '-fsanitize=undefined' for struct assignment statement
yangyibiao at hust dot edu.cn
gcc-bugzilla@gcc.gnu.org
Sun Feb 16 09:01:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93766
Bug ID: 93766
Summary: [GCOV] incorrect coverage when compiled with option
'-fsanitize=undefined' for struct assignment statement
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
#include <string.h>
typedef struct
{
int e;
} S;
inline __attribute__ ((always_inline)) void foo (S *y)
{
S c = *y;
}
void main (void)
{
S y;
memset (&y, 0, sizeof (y));
foo(&y);
}
$ gcc -O0 --coverage -fsanitize=undefined small.c; ./a.out; gcov small.c; cat
small.c.gcov
File 'small.c'
Lines executed:100.00% of 5
Creating 'small.c.gcov'
-: 0:Source:small.c
-: 0:Graph:small.gcno
-: 0:Data:small.gcda
-: 0:Runs:1
-: 1:#include <string.h>
-: 2:
-: 3:typedef struct
-: 4:{
-: 5: int e;
-: 6:} S;
-: 7:
-: 8:inline __attribute__ ((always_inline)) void foo (S *y)
-: 9:{
2: 10: S c = *y;
1: 11:}
-: 12:
1: 13:void main (void)
-: 14:{
-: 15: S y;
1: 16: memset (&y, 0, sizeof (y));
-: 17: foo(&y);
1: 18:}
####################################################
We can find that Line #10 is wrongly marked as executed twice.
When compiling without "-fsanitize=undefined", the coverage will be correct.
More information about the Gcc-bugs
mailing list