From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121881 invoked by alias); 2 May 2017 15:58:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 114120 invoked by uid 89); 2 May 2017 15:57:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 May 2017 15:57:33 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1F5029F4B0; Tue, 2 May 2017 15:57:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D1F5029F4B0 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jwakely@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D1F5029F4B0 Received: from localhost (unknown [10.33.36.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 758541BD87B; Tue, 2 May 2017 15:57:34 +0000 (UTC) Date: Tue, 02 May 2017 16:19:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] PR libstdc++/80553 don't allow destroying non-destructible types Message-ID: <20170502155733.GX5109@redhat.com> References: <20170428125629.GA14095@redhat.com> <20170502091633.GA8813@redhat.com> <20170502094602.GT5109@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.8.0 (2017-02-23) X-SW-Source: 2017-05/txt/msg00126.txt.bz2 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.