[Networkit] Possible bugs

Daniel Hoske daniel.hoske at student.kit.edu
Wed Jun 25 13:53:49 CEST 2014


Hi,

> That one isn't my department, so just a few general comments (The
> situation might be perfectly valid the way it is):
>
> * Deleting through a non-virtual base-pointer isn't a leak but undefined
> behavior → I would strongly recommend to consider code doing that as
> release-blockers.
> * Virtual Dtors are often overused: They rarely make much sense if you
> don't have another virtual method; Publicly inheriting from a class
> without vtable, sometimes IS a perfectly valid choice, but you should
> really know what you are doing and should document your rationale.
>
> Therefore: Everyone who uses a class derived from Matrix should review
> whether they are deleting an instance through a Matrix-pointer. This
> would be the case for `std::unique_ptr<Matrix>`; OTOH the following is
> valid:
>
> std::shared_ptr<Matrix> ptr = std::make_shared<DerivedMatrix>(g);
>
> Note that the following is not valid though (and slower and terrible code):
>
> std::shared_ptr<Matrix> ptr{new DerivedMatrix(g)};
thanks for the information. As far as I can tell, Matrix isn't actually 
used polymorphically anywhere. So the current usage should be fine. I'm 
not sure why the Intel Inspector declared it a memory leak.

Regards,
Daniel




More information about the NetworKit mailing list