Re: [Boost-users] [Boost.Test] valgrind complains about invalid reads

I agree with Peter here, the destructor for test_unit should be virtual. I find that it is being deleted when test_unit* is a stored in reference counted pointer, and at program exit it is being deleted by calling ~test_unit(). If you use a derived class (test_suite), this is leading to an error. Also, in the code I'm looking at (1.40.0), the test_suite class has a virtual destructor, but its base class test_unit does not. Not making the base class virtual seems to be defeating the purpose. Scott

Scott Banachowski
I agree with Peter here, the destructor for test_unit should be virtual.
'Should' is a strong statement. Do you have anything to based it on?
I find that it is being deleted when test_unit* is a stored in reference counted pointer,
Where?
and at program exit it is being deleted by calling ~test_unit().
Where do I call destructor explicitly?
If you use a derived class (test_suite), this is leading to an error.
Where?
Also, in the code I'm looking at (1.40.0), the test_suite class has a virtual destructor, but its base class test_unit does not. Not making the base class virtual seems to be defeating the purpose.
What purpose? The only reason that test_suite destructor is virtual is because this class in fact is being polymorphically. It has subclass master_test_suite. Gennadiy
participants (2)
-
Gennadiy Rozental
-
Scott Banachowski