This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Make dwarf_expr_context's destructor virtual
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 25 Oct 2016 13:46:46 -0000
- Subject: [binutils-gdb] Make dwarf_expr_context's destructor virtual
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=beb18c865c42ab57176099eecb65bb52e71def85
commit beb18c865c42ab57176099eecb65bb52e71def85
Author: Pedro Alves <palves@redhat.com>
Date: Tue Oct 25 14:32:35 2016 +0100
Make dwarf_expr_context's destructor virtual
Ref: https://sourceware.org/ml/gdb-patches/2016-10/msg00662.html
$ make WERROR_CFLAGS="-Wnon-virtual-dtor" dwarf2expr.o
...
In file included from .../src/gdb/dwarf2expr.c:28:0:
.../src/gdb/dwarf2expr.h:68:8: warning: â??struct dwarf_expr_contextâ?? has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
struct dwarf_expr_context
^~~~~~~~~~~~~~~~~~
Happens to not be a problem in practice currently because concrete
subclasses are allocated on the stack. I.e., we don't ever delete
objects of types that derive from dwarf_expr_context through pointers
to dwarf_expr_context.
gdb/ChangeLog:
2016-10-25 Pedro Alves <palves@redhat.com>
* dwarf2expr.h (struct dwarf_expr_context) <~dwarf_expr_context>:
Make virtual.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/dwarf2expr.h | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 10d6866..91f36f9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-25 Pedro Alves <palves@redhat.com>
+
+ * dwarf2expr.h (struct dwarf_expr_context) <~dwarf_expr_context>:
+ Make virtual.
+
2016-10-25 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR build/20712
diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h
index 7bf194a..3d08120 100644
--- a/gdb/dwarf2expr.h
+++ b/gdb/dwarf2expr.h
@@ -68,7 +68,7 @@ struct dwarf_stack_value
struct dwarf_expr_context
{
dwarf_expr_context ();
- ~dwarf_expr_context ();
+ virtual ~dwarf_expr_context ();
void push_address (CORE_ADDR value, int in_stack_memory);
void eval (const gdb_byte *addr, size_t len);