From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105731 invoked by alias); 17 Sep 2018 15:45:58 -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 105705 invoked by uid 89); 17 Sep 2018 15:45:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Glisse, Marc, marc, glisse 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; Mon, 17 Sep 2018 15:45:56 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3912C058CAD; Mon, 17 Sep 2018 15:45:55 +0000 (UTC) Received: from localhost (unknown [10.33.36.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DE527A003; Mon, 17 Sep 2018 15:45:55 +0000 (UTC) Date: Mon, 17 Sep 2018 16:29:00 -0000 From: Jonathan Wakely To: Marc Glisse Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: vector _M_start and 0 offset Message-ID: <20180917154554.GP23172@redhat.com> References: 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.9.2 (2017-12-15) X-SW-Source: 2018-09/txt/msg00882.txt.bz2 On 15/09/18 14:27 +0200, Marc Glisse wrote: >Hello, > >as explained in the PR, the implementation of vector is weirdly >wasteful. Preserving the ABI prevents from changing much for now, but >this small tweak can help the compiler remove quite a bit of dead >code. > >I think most other direct uses of _M_start are in constructors where >the offset has just been initialized to 0, so the compiler should >already know enough there, but I may have missed a few relevant places >where the same idea could be used. > >I used C++11 syntax because I find it nicer, and the compiler accepts >it in C++98 mode with just a warning, suppressed in a standard header. > >Bootstrap+regtest on powerpc64le-unknown-linux-gnu. > >2018-09-15 Marc Glisse > > PR libstdc++/87258 > * include/bits/stl_bvector.h (vector::begin(), vector::cbegin()): > Rebuild _M_start with an explicit 0 offset. > >-- >Marc Glisse >Index: include/bits/stl_bvector.h >=================================================================== >--- include/bits/stl_bvector.h (revision 264178) >+++ include/bits/stl_bvector.h (working copy) >@@ -802,25 +802,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER > #endif > > #if __cplusplus >= 201103L > void > assign(initializer_list __l) > { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } > #endif > > iterator > begin() _GLIBCXX_NOEXCEPT >- { return this->_M_impl._M_start; } >+ { return { this->_M_impl._M_start._M_p, 0 }; } > > const_iterator > begin() const _GLIBCXX_NOEXCEPT >- { return this->_M_impl._M_start; } >+ { return { this->_M_impl._M_start._M_p, 0 }; } Won't this fail to compile in C++98 mode?