Hello,

Could anyone explain to me why the following C++ class's destructor
shows up as having multiple branches?  (At least as judged by gcov
when compiled with g++ 4.1.2 ).  This was run on Red Hat Enterprise
Linux 5.

struct blah
{
  blah();
  virtual ~blah();
};

blah::blah()
{
}

blah::~blah()
{
}

int main()
{
  blah myBlah;

  return 0;
}

The output from gcov showing these branches (with 1 not taken):

        1:   11:blah::~blah()
        -:   12:{
        1:   13:}
branch  0 never executed
branch  1 never executed
call    2 never executed
branch  3 taken 0 (fallthrough)
branch  4 taken 1
call    5 never executed
branch  6 never executed
branch  7 never executed
call    8 never executed

Please note that if I make the destructor non-virtual, the branches go
away.  I'm particularly curious if there are any compiler switches or
options to gcov to get these branches to go away.  This would be for
the purposes of preparing a code coverage report only, not production
code.


Thanks!

Reply via email to