diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-12-07 11:48:21 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-12-07 11:49:01 -0500 |
commit | 30970df7d56bd65657c97296f31fe9862bf27e1d (patch) | |
tree | 90833cacb8f8c75fd7ff890d86cfa9f56a8b9fca /gdb/common | |
parent | 824cc835aa9a4d585d955db4ab2a5dd4c17cc22c (diff) | |
download | gdb-30970df7d56bd65657c97296f31fe9862bf27e1d.zip gdb-30970df7d56bd65657c97296f31fe9862bf27e1d.tar.gz gdb-30970df7d56bd65657c97296f31fe9862bf27e1d.tar.bz2 |
Add virtual destructor to selftest
Clang 6 shows this warning
In file included from /home/emaisin/src/binutils-gdb/gdb/common/selftest.c:19:
In file included from /home/emaisin/src/binutils-gdb/gdb/common/common-defs.h:92:
In file included from /home/emaisin/src/binutils-gdb/gdb/common/gdb_unique_ptr.h:23:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/memory:81:
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:76:2: error: delete called on 'selftests::selftest' that is abstract but has non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
delete __ptr;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:236:4: note: in instantiation of member function 'std::default_delete<selftests::selftest>::operator()' requested here
get_deleter()(__ptr);
^
/home/emaisin/src/binutils-gdb/gdb/common/selftest.c:57:17: note: in instantiation of member function 'std::unique_ptr<selftests::selftest, std::default_delete<selftests::selftest> >::~unique_ptr' requested here
tests[name] = std::unique_ptr<selftest> (test);
^
The error is legitimate, we (the unique_ptr) are deleting selftest
objects through the base pointer, so technically the destructor should
be virtual, so that the destructor of the subclass is invoked.
gdb/ChangeLog:
* common/selftest.h (struct selftest): Add virtual destructor.
Diffstat (limited to 'gdb/common')
-rw-r--r-- | gdb/common/selftest.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gdb/common/selftest.h b/gdb/common/selftest.h index 35a344f..7e91bd4 100644 --- a/gdb/common/selftest.h +++ b/gdb/common/selftest.h @@ -31,6 +31,7 @@ namespace selftests struct selftest { + virtual ~selftest () = default; virtual void operator() () const = 0; }; |