http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58602
Bug ID: 58602 Summary: .gcno files not truncated at gcov_close Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: laurent.alfonsi at st dot com Created attachment 30950 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30950&action=edit script to reproduce Gcc doesnot clean the .gcno file before writing in. Thus, it might contain garbage at the end. At one point, it was truncated, but this has been removed. http://gcc.gnu.org/ml/gcc-patches/2004-07/msg02541.html Test case : $ rm test.gcno $ gcc -ftest-coverage -fprofile-arcs test.c -O3 $ ls -la test.gcno -rw-r--r-- 1 alfonsi gnbcomp 688 Oct 3 11:57 test.gcno $ gcc -ftest-coverage -fprofile-arcs test.c -O0 $ ls -la test.gcno -rw-r--r-- 1 alfonsi gnbcomp 908 Oct 3 11:57 test.gcno $ gcc -ftest-coverage -fprofile-arcs test.c -O3 $ ls -la test.gcno -rw-r--r-- 1 alfonsi gnbcomp 908 Oct 3 11:58 test.gcno As you may see, the last 220 bytes are garbage from the preceding O0 compilation. I enclosed a small script that expose the problem. This has been trackeddown from a kernel issue on lcov: http://sourceforge.net/p/ltp/mailman/message/31141937/