From: Simon Marchi <simon.marchi@polymtl.ca>
To: "Павел Крюков" <kryukov@frtk.ru>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Make dtor of mapped_index_base virtual
Date: Sun, 31 Dec 2017 13:49:00 -0000 [thread overview]
Message-ID: <85ac4a723847708e1f2b49f90038a936@polymtl.ca> (raw)
In-Reply-To: <CADip9gZyJP7Dk4CUUwTzgz=fdn=fgM9BMfofTv_0Yptf2jzFZA@mail.gmail.com>
On 2017-12-31 05:12, Ðавел ÐÑÑков wrote:
> Hi Simon
>
>> Do you get a build error or something?
>
> Yes, I get a build error with Clang:
>
> dwarf2read.c:25409:5: error: destructor called on non-final
> 'mapped_index'
> that
> has virtual functions but non-virtual destructor
> [-Werror,-Wdelete-non-virtual-dtor]
> data->index_table->~mapped_index ();
>
>> Since the goal is that we don't delete through a pointer of this
>> class, does
> the destructor need to be virtual (not that it would hurt anything)?
>
> Just to handle the case if someone would delete through a pointer to
> "mapped_index_base" class.
>
> Thanks,
Hi Pavel,
I think this warning was fixed by the following commit:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=fc898b42e355fef58e6a029799fdd71b9dda5dc6
We don't want anything deleting through a pointer of the base class,
because (for now) instances of the two child classes (mapped_index and
mapped_debug_names) are allocated differently. One is allocated on the
objfile obstack (some kind of manual memory block allocation) and the
other is allocated with new. Trying to delete or manually call the
destructor through a pointer to mapped_index_base would do the wrong
thing for one of the two children. So it's on purpose that
mapped_index_base's destructor is hidden, and it doesn't matter whether
or not it is virtual.
Thanks,
Simon
prev parent reply other threads:[~2017-12-31 13:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-30 18:21 Павел Крюков
2017-12-31 1:28 ` Simon Marchi
2017-12-31 10:12 ` Павел Крюков
2017-12-31 13:49 ` Simon Marchi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85ac4a723847708e1f2b49f90038a936@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=kryukov@frtk.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).