Bug 11773 - GCOV misreports coverage for in-class C++ member functions
Summary: GCOV misreports coverage for in-class C++ member functions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: 3.4.0
Assignee: Nathan Sidwell
URL:
Keywords: documentation
Depends on:
Blocks:
 
Reported: 2003-08-02 19:31 UTC by Yuri
Modified: 2005-07-23 22:49 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-11-28 08:10:49


Attachments
testcases (411 bytes, application/x-gzip)
2003-08-24 22:08 UTC, Dara Hazeghi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri 2003-08-02 19:31:25 UTC
Code (see uuencoded file src.tgz at the end of the message)
being compiled with command:
> g++ -fprofile-arcs -ftest-coverage *.cc -o tst
Then program is being run:
> ./tst
Then gcov being run:
> gcov -l a.cc
> gcov -l b.cc

WRONG RESULT OBTAINED:
in b.cc.a.h.gcov I find:
 <snip>
                void
      ######    a() {
      ######      printf("AA\n");
                }
 <snip>
this report means that function A::a() isn't used in b.cc
In fact as seen in sources it's invoked from b.cc.

Thanx,
Yuri.

--------- code ----------------------------------------------
begin 644 src.tgz
M'XL(`)X0+#\``^V644^#,!"`>>ZON.#+9A3;44;BC,GP;_A2"@K)9`N%1;/L
MOWNLFT9T\@1;LOM>#CB@38_OBBGUG=,SG$L>!@%&SL-P:N-4[N(>!Q/"YX)/
M)L+!$(3<@:#OB374IE(E@/-1E_G_]Z6E&6)"PV*P_LK3NL\QL)Y\*N71^D^$
M;-5?^$(XP/N<U($+K_]57NA%G:3@*B]SV?=IW)RR]+U*RP+6RSP!/1K/&,N+
MBKVIO!CA`:CR5=^`7A:F`IWA.E[CE?48-@Q@#FJ&(8(8GP)0GFJ>!XB]V![@
M9[=[(]@W;]FIU^(2:?R/3^R_D/YO_WWR?P@Z_&>-^0S]_$OI58D]X&7DWB+/
MA3MN>TY:GS]V_\]Z':-[_V___PDA0_)_"+Z$?S!5DB^][)$QO5#&H.P;MJKC
M1:[O;1=0^RYPT'X^M])O]UTB;N>CGWG=SC\=\ML9-8D38??_\_,_X.3_$!SW
H/^KR/^KP/^KP/R+_"8(@"((@"((@"((@"((@"*(?/@&S1(U$`"@`````
`
end
Comment 1 Yuri 2003-08-07 07:21:55 UTC
From yuri@tsoft.com:
CORRECTION (reformulation):
After some experimentation I figured that
####### actually means "used" butwhycounter didn't appear?
Is this a bug?
In another header actual counters appeared.
Comment 2 Dara Hazeghi 2003-08-24 22:08:54 UTC
Created attachment 4647 [details]
testcases

Please use bugzilla's "create new attachment" to add files to bug reports,
rather than including them in the message. Not only does it make my life
easier, it also makes the audit trail more intelligible.
Comment 3 Dara Hazeghi 2003-08-24 22:12:29 UTC
Nathan, would you mind clarify whether the reported behavior is a bug? Thanks.
Comment 4 Nathan Sidwell 2003-08-24 22:16:49 UTC
will investigate
Comment 5 Nathan Sidwell 2003-09-06 18:53:56 UTC
not a bug, but an outcome of inline functions and weak linkage. I used
the current mainline, which mangles gcov file names differently.

You'll see (well I did) that a.cc##a.h contains 2 counts
for A::a. so overall, the execution counts are correct, just not where
you expected them. What is happening is this,
1) you're compiling without optimization, thus function calls are not inlined.
2) both a.cc and b.cc need to emit a body of A::a, which they each call.
3) those A::a functions are emitted with weak linkage, which means one of them
will 'win' in the linking phase.
4) at the linking phase the A::a emitted in a.o is selected, and the call of
A::a in b.o ends up calling the body of A::a that was emitted in a.o
5) thus the body of A::a emitted in b.o is never called.

need to write something in the documentation about this.
Comment 6 Nathan Sidwell 2003-12-15 14:26:37 UTC
2003-12-15  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/11773
	* doc/gcov.texi (Gcov and Optimization): Document inline function
	behaviour. Fix some file suffixes.
Comment 7 GCC Commits 2003-12-15 14:29:16 UTC
Subject: Bug 11773

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	nathan@gcc.gnu.org	2003-12-15 14:29:11

Modified files:
	gcc            : ChangeLog 
	gcc/doc        : gcov.texi 

Log message:
	PR c++/11773
	* doc/gcov.texi (Gcov and Optimization): Document inline function
	behaviour.  Fix some file suffixes.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1995&r2=2.1996
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/gcov.texi.diff?cvsroot=gcc&r1=1.18&r2=1.19

Comment 8 The gcc-bugs mailing list 2003-12-15 18:32:36 UTC
Documentation fixed for 3.4.