From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4493 invoked by alias); 6 Oct 2016 21:34:13 -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 4472 invoked by uid 89); 6 Oct 2016 21:34:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=noexcept, _Base_ptr, defaulting, _m_key_compare 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; Thu, 06 Oct 2016 21:34:11 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 C093285376; Thu, 6 Oct 2016 21:34:09 +0000 (UTC) Received: from localhost (ovpn-116-122.ams2.redhat.com [10.36.116.122]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u96LY8Nc017430; Thu, 6 Oct 2016 17:34:09 -0400 Date: Thu, 06 Oct 2016 21:34: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: <20161006213408.GU29482@redhat.com> References: <20161005115617.GA5501@redhat.com> <20161005121309.GM29482@redhat.com> <4d30deb3-8720-2aa6-d0f2-94f6fca44825@gmail.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: <4d30deb3-8720-2aa6-d0f2-94f6fca44825@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.0 (2016-08-17) X-SW-Source: 2016-10/txt/msg00425.txt.bz2 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? >I'll try to do the same for copy constructor/assignment and move >constructor/assignment. We need to make sure we don't change whether any of those operations are trivial (which shouldn't be a problem for copy/move, because they are definitely very non-trivial and will stay that way!) Does this change the default constructors from non-trivial to trivial? >--- a/libstdc++-v3/include/bits/stl_tree.h >+++ b/libstdc++-v3/include/bits/stl_tree.h >@@ -108,6 +108,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > _Base_ptr _M_left; > _Base_ptr _M_right; > >+ _Rb_tree_node_base() _GLIBCXX_NOEXCEPT >+ : _M_color(_S_red), _M_parent(0), _M_left(this), _M_right(this) >+ { } >+ > static _Base_ptr > _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT > { Another option would be: struct _Head_node : _Rb_tree_node_base { _Head_node() { _M_color = _S_red; _M_parent = _Base_ptr(); _M_left = _M_right = this; } }; >@@ -603,23 +607,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > { > _Key_compare _M_key_compare; > _Rb_tree_node_base _M_header; _Head_node _M_header; That way *only* this node gets the zero-initialization, not all node bases. With either solution we can get rid of _M_header() in every ctor-initializer-list. >+#if __cplusplus < 201103L > size_type _M_node_count; // Keeps track of size of tree. >+#else >+ size_type _M_node_count = 0; // Keeps track of size of tree. >+#endif > >+#if __cplusplus < 201103L > _Rb_tree_impl() > : _Node_allocator(), _M_key_compare(), _M_header(), > _M_node_count(0) >- { _M_initialize(); } >+ { } >+#else >+ _Rb_tree_impl() = default; >+#endif > > _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a) >- : _Node_allocator(__a), _M_key_compare(__comp), _M_header(), >- _M_node_count(0) >- { _M_initialize(); } >+ : _Node_allocator(__a), _M_key_compare(__comp), _M_header() >+#if __cplusplus < 201103L >+ , _M_node_count(0) >+#endif Doing this conditionally seems pointless, why not just set it here unconditionally?