public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Tobias Burnus <tobias.burnus@physik.fu-berlin.de>,
	gcc-patches@gcc.gnu.org
Subject: Re: PR C++/88114 - patch for destructor not generated for "virtual ~destructor() = default"
Date: Fri, 11 Jan 2019 18:57:00 -0000	[thread overview]
Message-ID: <ae774fd2-6fe2-51e7-114c-3e51adcd2f54@redhat.com> (raw)
In-Reply-To: <20190111183641.4n3tb4kb4iqks4ib@physik.fu-berlin.de>

On 1/11/19 1:36 PM, Tobias Burnus wrote:
> Dear Jason, dear all,
> 
> Jason Merrill wrote on 5 Dec 2018:
>> You can get at the destructor with CLASSTYPE_DESTRUCTOR rather than walking through TYPE_FIELDS. I'd also check DECL_DEFAULTED_IN_CLASS_P.
>> I'd also do this in maybe_emit_vtables rather than here, so that it only happens once per class.
> 
> Updated patch. I also added a test case which checks that the destructor
> is not generated.
> 
> [ Original patch: https://gcc.gnu.org/ml/gcc-patches/2018-11/msg01824.html ]
> 
> Background again:
>     If a class contains any 'virtual ... = 0', it's an abstract class and for an
>     abstract class, the destructor not added to the vtable.
> 
>     For a normal
>       virtual ~class() { }
>     that's not a problem as the class::~class() destructor will be generated during
>     the parsing of the function.
> 
>     But for
>       virtual ~class() = default;
>     the destructor will be generated via mark_used via the vtable.
> 
>     If one now declares a derived class and uses it, the class::~class() is generated
>     in that translation unit.  Unless, #pragma interface/implementation is used.
> 
>     In that case, the 'default' destructor will never be generated.
> 
> Build and regtested on x86_64-gnu-linux.
> OK? Or do you have more suggested changes?

> +      && DECL_DEFAULTED_IN_CLASS_P(CLASSTYPE_DESTRUCTOR(ctype))
> +      && DECL_DEFAULTED_FN (CLASSTYPE_DESTRUCTOR(ctype)))

Checking DECL_DEFAULTED_FN again is redundant, it's checked by 
DECL_DEFAULTED_IN_CLASS_P.  OK with that last condition removed.

Jason

      reply	other threads:[~2019-01-11 18:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 12:19 Tobias Burnus
2018-11-25  8:44 ` *ping* – PR C++/88114 - PATCH " Tobias Burnus
2018-11-28 20:36   ` *ping*^2 " Tobias Burnus
2018-12-04 12:42     ` *PING*^3 [C++ Patch] " Tobias Burnus
2018-12-05 22:50 ` PR C++/88114 - patch " Jason Merrill
2019-01-11 18:36   ` Tobias Burnus
2019-01-11 18:57     ` Jason Merrill [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=ae774fd2-6fe2-51e7-114c-3e51adcd2f54@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias.burnus@physik.fu-berlin.de \
    /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).