From 07d262cd1ea500090bac724e9d53076d8c932bdc Mon Sep 17 00:00:00 2001 From: Dominik Gleich Date: Thu, 18 Jan 2018 17:23:58 +0100 Subject: [PATCH] Add virtual destructors Summary: Virtual destructors were missing in classes/structs which can be inherited. A missing virtual destructor gives undefined behaviour when deleting derived class using base type. Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1117 --- src/storage/types.hpp | 1 + src/utils/total_ordering.hpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/storage/types.hpp b/src/storage/types.hpp index 523fe6068..912e0842f 100644 --- a/src/storage/types.hpp +++ b/src/storage/types.hpp @@ -16,6 +16,7 @@ class Common : public TotalOrdering { Common() {} explicit Common(const StorageT storage) : storage_(storage) {} + virtual ~Common() {} friend bool operator==(const TSpecificType &a, const TSpecificType &b) { return a.storage_ == b.storage_; diff --git a/src/utils/total_ordering.hpp b/src/utils/total_ordering.hpp index 5295ad32f..b31136291 100644 --- a/src/utils/total_ordering.hpp +++ b/src/utils/total_ordering.hpp @@ -11,6 +11,8 @@ */ template struct TotalOrdering { + virtual ~TotalOrdering() {} + friend constexpr TReturn operator!=(const TLhs& a, const TRhs& b) { return !(a == b); } @@ -30,6 +32,8 @@ struct TotalOrdering { template struct TotalOrderingWith { + virtual ~TotalOrderingWith() {} + friend constexpr bool operator!=(const Derived& a, const T& b) { return !(a == b); }