gcov bug
Kevin Lai
laik@tnt.stanford.edu
Tue Feb 29 19:14:00 GMT 2000
gcov incorrectly counts the number of times that the last line of a
function (containing the close brace) is executed. This only happens
when the function returns a value. The test program and its gcov
output are included.
os: GNU/Linux
kernel: 2.2.12-20
distribution: Redhat 6.1
gcc: gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
gcc package: egcs-1.1.2-24
gcc options: -fprofile-arcs -ftest-coverage -g -pg
gcov: GNU gcov version 1.5
test program:------------------------
#include <stdlib.h>
inline static void *
foo(void *a)
{
if (a == NULL) {
a = NULL;
}
return a;
}
int
main(int argc, char * const argv[])
{
void *b;
b = foo(NULL);
return 0;
}
gcov output:------------------------
#include <stdlib.h>
inline static void *
foo(void *a)
{
1 if (a == NULL) {
1 a = NULL;
1 }
1 return a;
###### }
int
main(int argc, char * const argv[])
{
1 void *b;
1 b = foo(NULL);
1 return 0;
1 }
More information about the Gcc-bugs
mailing list