http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46266
Summary: gcov generates data for non-existing file <built-in>
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
AssignedTo: [email protected]
ReportedBy: [email protected]
Using gcov on data from a binary compiled with options -std=c99 and -coverage
results in gcov trying to access a non-existing source file <built-in>.
How to reproduce:
# echo "int main(){}" > x.c
# gcc x.c -o x -std=c99 -coverage
# ./x
# gcov x
File 'x.c'
Lines executed:100.00% of 1
x.c:creating 'x.c.gcov'
File '<built-in>'
No executable lines
# cat '<built-in>.gcov'
-: 0:Source:<built-in>
-: 0:Graph:x.gcno
-: 0:Data:x.gcda
-: 0:Runs:1
-: 0:Programs:1
gcc versions on which this behavior was observed:
- Using built-in specs.
Target: s390x-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.3 --enable-ssp --disable-libssp
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.3
--enable-linux-futex --without-system-libunwind --with-tune=z9-109
--with-arch=z900 --with-long-double-128 --enable-decimal-float
--build=s390x-suse-linux
Thread model: posix
gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux)
- Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --enable-multiarch --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4
--program-suffix=-4.4 --enable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
The reason for this behavior seems to be that gcc adds an implicit "return 0"
statement for main() (likely to comply with ISO/IEC 9899, section 5.1.2.2.3)
and refers to that from the .gcno file.
My expectation would be that gcov should disregard any data for code added
implicitly by gcc. Ideally this code should also be excluded from profiling
during compilation (i.e. no reference in .gcno files, no extra arc profiling
code).