From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108098 invoked by alias); 9 Oct 2016 15:38:44 -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 108038 invoked by uid 89); 9 Oct 2016 15:38:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=highly 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; Sun, 09 Oct 2016 15:38:42 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D675D8553C; Sun, 9 Oct 2016 15:38:40 +0000 (UTC) Received: from localhost (ovpn-116-122.ams2.redhat.com [10.36.116.122]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u99FceBQ015713; Sun, 9 Oct 2016 11:38:40 -0400 Date: Sun, 09 Oct 2016 15:38:00 -0000 From: Jonathan Wakely To: =?iso-8859-1?Q?Fran=E7ois?= Dumont Cc: libstdc++@gcc.gnu.org, gcc-patches Subject: Re: [PATCH] 77864 Fix noexcept conditions for map/set default constructors Message-ID: <20161009153839.GC25380@redhat.com> References: <20161005115617.GA5501@redhat.com> <20161005121309.GM29482@redhat.com> <4d30deb3-8720-2aa6-d0f2-94f6fca44825@gmail.com> <20161006213408.GU29482@redhat.com> <60454696-88fc-d7c0-12f5-b0f7e960dba8@gmail.com> <20161009151451.GB25380@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161009151451.GB25380@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.0 (2016-08-17) X-SW-Source: 2016-10/txt/msg00561.txt.bz2 On 09/10/16 16:14 +0100, Jonathan Wakely wrote: >On 08/10/16 22:55 +0200, François Dumont wrote: >>On 06/10/2016 23:34, Jonathan Wakely wrote: >>>On 06/10/16 22:17 +0200, François Dumont wrote: >>>>Another approach is to rely on existing compiler ability to >>>>compute conditional noexcept when defaulting implementations. >>>>This is what I have done in this patch. >>>> >>>>The new default constructor on _Rb_tree_node_base is not a >>>>problem as it is not used to build _Rb_tree_node. >>> >>>Why not? >> >>_Rb_tree_node_base is used in 2 context. As member of _Rb_tree_impl >>in which case we need the new default constructor. And also as base >>class of _Rb_tree_node which is never constructed. Nodes are being >>allocated and then associated value is being constructed through the >>allocator, the node default constructor itself is never invoked. > >In C++03 mode that is true, but it's only valid because the type is >trivially-constructible. If the type requires "non-vacuous >initialization" then it's not valid to allocate memory for it and >start using it without invoking a constructor. If you add a >non-trivial constructor then we can't do that any more. In fact that code is highly questionable, because the element member makes the node require non-trivial initialization. We rely on the base being trivially-constructible, and the element being constructed by the allocator, and assume that it's OK to then treat that memory as a node. In fact only its base class and member have been constructed, not the node itself. The C++11 version (using an aligned buffer) is correct. But I'd prefer not to make the C++98 version worse.