This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16855] New: gcov does not report the fact that static destructors actually run.


If you compile a c++ program that has static objects with the -fprofile-arcs -
ftest-coverage switches and link with -lgcov, then run the program and produce 
a report with gcov, then static destructors are reported not to have run.
These destructors do in fact run, its just that gcov doesn't detect them.

I'm running djgpp 3.4.1 under Windows XP.
The program below is compiled using the batch file and the gcov output is 
shown below that.

Example program:
===============
// Test constructors/destructors:
#include <iostream>
using namespace std;
class Test {
public:
	Test(void){
	cout<< "In Test ctor" << endl;
	}
	~Test(void){
	cout<< "In Test dtor" << endl;
	}
}T1;

void uncalled(void){
	cout<< "In uncalled" << endl;
}
int main(void){
// Test T2;
cout<< "In main" << endl;
return 0;
}
===============

Testctor.bat:
===============
gpp -o testctor.exe testctor.cpp -fprofile-arcs -ftest-coverage -lgcov
testctor.exe
gcov testctor.cpp
===============
which shows how I compiled the above source file, ran the resulting program 
and ran gcov to produce a .gcov output.

testctor.cpp.gcov
===============
        -:    0:Source:testctor.cpp
        -:    0:Graph:testctor.gcno
        -:    0:Data:testctor.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:// Test constructors/destructors:
        -:    2:#include <iostream>
        -:    3:using namespace std;
        -:    4:class Test {
        -:    5:public:
function _ZN4TestC1Ev called 1 returned 100% blocks executed 100%
        1:    6:	Test(void){
        1:    7:	cout<< "In Test ctor" << endl;
        -:    8:	}
function _ZN4TestD1Ev called 0 returned 0% blocks executed 0%
    #####:    9:	~Test(void){
    #####:   10:	cout<< "In Test dtor" << endl;
        -:   11:	}
        1:   12:}T1;
        -:   13:
function _Z8uncalledv called 0 returned 0% blocks executed 0%
    #####:   14:void uncalled(void){
    #####:   15:	cout<< "In uncalled" << endl;
        -:   16:}
function main called 1 returned 100% blocks executed 100%
        1:   17:int main(void){
        -:   18:// Test T2;
        1:   19:cout<< "In main" << endl;
        1:   20:return 0;
function _Z41__static_initialization_and_destruction_0ii called 1 returned 
100% blocks executed 76%
        2:   21:}
function _GLOBAL__I_T1 called 1 returned 100% blocks executed 100%
        2:   22:/*EOF*/
function _GLOBAL__D_T1 called 0 returned 0% blocks executed 0%
    #####:   23:/*EOF*/
===============

-- 
           Summary: gcov does not report the fact that static destructors
                    actually run.
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wallguide-software at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16855


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]