public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] PR libstdc++/80553 don't allow destroying non-destructible types
Date: Tue, 02 May 2017 16:19:00 -0000	[thread overview]
Message-ID: <20170502155733.GX5109@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1705021727220.14339@stedding.saclay.inria.fr>

On 02/05/17 17:30 +0200, Marc Glisse wrote:
>On Tue, 2 May 2017, Jonathan Wakely wrote:
>
>>On 02/05/17 10:16 +0100, Jonathan Wakely wrote:
>>>On 28/04/17 13:56 +0100, Jonathan Wakely wrote:
>>>>We optimize _Destroy and _Destroy_n to do nothing when the type has a
>>>>trivial destructor, which means we do nothing (instead of giving an
>>>>error) when trying to destroy types with deleted destructors.
>>>
>>>I wonder if this optimisation should even exist. The compiler should
>>>be able to optimise away a loop that just calls trivial destructors,
>>>without help from the library.
>>
>>The compiler can indeed do that optimisation, even for destructors
>>like ~T() { } that are empty, but not trivial according to the
>>language rules. The libstdc++ optimisation does make a difference at
>>-O0 though. If we get any more bugs in that code I think we should
>>just remove it though, and let the compiler do the right thing.
>
>Does the compiler manage it for all containers, even those with 
>iterators much more complicated than vector's?

It seems to for std::deque (not very complicated) and std::map
(moderately complicated). I didn't try for something like a
directory_iterator which almost certainly wouldn't get optimised away!

>I'd rather keep the 
>special code in the library, if it doesn't cause too much trouble.

Yes, assuming the code's correct now then we might as well keep it,
but if it's a source of too many more bugs then it starts to cause too
much trouble.


      reply	other threads:[~2017-05-02 15:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 13:33 Jonathan Wakely
2017-05-02  9:17 ` Jonathan Wakely
2017-05-02  9:52   ` Jonathan Wakely
2017-05-02 15:31     ` Marc Glisse
2017-05-02 16:19       ` Jonathan Wakely [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=20170502155733.GX5109@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /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).