Reputation: 703
My working environment
cygwin
lcov 1.13
GCC 5.4.0
Problem is coverage report in html told that missing branch in destructor but the destructor is empty. I don't know why. Anyone can help me ? I also try with GCC 4.8.0 but same result
Upvotes: 0
Views: 2076
Reputation: 8122
A simple solution is to add // GCOVR_EXCL_LINE
as a comment to your line that you know is not executing both branches. I think this is a good idea for this case, as from my understanding there isn't another way to force GCOV to take both dynamic and non-dynamic branches of the destructor.
For example:
TestClass *a = new TestClass;
delete a; // GCOVR_EXCL_LINE
will exclude the delete a;
line from the coverage report.
See the following for more details: https://gcovr.com/en/master/guide.html#exclusion-markers
Upvotes: 0
Reputation: 31
I had the same problem and I found this on stackoverflow. The short answer is that there are different types of destructors, depending on whether you delete a dynamically allocated object, or is a statically allocated object destructed.
So to get rid of this missing branch coverage, you have to create an object with
TestClass* a = new TestClass();
and
TestClass b;
and then make sure, they are both destroyed, the former, of course, with
delete a;
Then both types of destructor should be called.
Upvotes: 3