Skip to content

Commit

Permalink
Fix warnings covered by -Wdelete-non-virtual-dtor
Browse files Browse the repository at this point in the history
The warnings were:

 src/cc/bcc_syms.cc: In function ‘void bcc_free_symcache(void*, int)’:
 src/cc/bcc_syms.cc:217:40: warning: deleting object of polymorphic class type ‘KSyms’
                            which has non-virtual destructor might cause undefined behaviour
                            [-Wdelete-non-virtual-dtor]
     delete static_cast<KSyms*>(symcache);
                                        ^
 src/cc/bcc_syms.cc:219:43: warning: deleting object of polymorphic class type ‘ProcSyms’
                            which has non-virtual destructor might cause undefined behaviour
                            [-Wdelete-non-virtual-dtor]
     delete static_cast<ProcSyms*>(symcache);
                                           ^

Fix the warnings by defining a virtual destructor for the base class SymbolCache.

Signed-off-by: Marco Leogrande <[email protected]>
  • Loading branch information
Marco Leogrande committed Nov 8, 2016
1 parent 9188d9b commit 899520c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cc/syms.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ProcStat {

class SymbolCache {
public:
virtual ~SymbolCache() = default;

virtual void refresh() = 0;
virtual bool resolve_addr(uint64_t addr, struct bcc_symbol *sym) = 0;
virtual bool resolve_name(const char *module, const char *name,
Expand Down

0 comments on commit 899520c

Please sign in to comment.