From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16294 invoked by alias); 2 Aug 2013 07:37:05 -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 16260 invoked by uid 89); 2 Aug 2013 07:37:05 -0000 X-Spam-SWARE-Status: No, score=-5.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_MED,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE,RDNS_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from Unknown (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 02 Aug 2013 07:37:04 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r727at5F001099 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 Aug 2013 07:36:56 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r727asV4016962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 2 Aug 2013 07:36:55 GMT Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r727ar01000466; Fri, 2 Aug 2013 07:36:53 GMT Received: from poldo4.casa (/79.45.212.101) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Aug 2013 00:36:53 -0700 Message-ID: <51FB6192.9080309@oracle.com> Date: Fri, 02 Aug 2013 07:37:00 -0000 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Gabriel Dos Reis CC: David Edelsohn , Francois Dumont , Jonathan Wakely , "libstdc++@gcc.gnu.org" , GCC Patches Subject: Re: PR 57779 New debug check References: <51FB578B.7030300@oracle.com> In-Reply-To: <51FB578B.7030300@oracle.com> Content-Type: multipart/mixed; boundary="------------020005030609050700040204" X-Virus-Found: No X-SW-Source: 2013-08/txt/msg00069.txt.bz2 This is a multi-part message in MIME format. --------------020005030609050700040204 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 54 ... applied this. Thanks, Paolo. ////////////////// --------------020005030609050700040204 Content-Type: text/plain; charset=UTF-8; name="CL_58049" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="CL_58049" Content-length: 387 2013-08-02 Paolo Carlini PR libstdc++/58049 * include/debug/functions.h: Include ; minor formatting changes. (__foreign_iterator_aux4): Declare __l and __ge constexpr. * include/debug/safe_iterator.h (_Safe_iterator<>::operator->): Use __addressof. * include/debug/safe_local_iterator.h (_Safe_local_iterator<>:: operator->): Likewise. --------------020005030609050700040204 Content-Type: text/plain; charset=UTF-8; name="patch_58049" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch_58049" Content-length: 5217 Index: include/debug/functions.h =================================================================== --- include/debug/functions.h (revision 201423) +++ include/debug/functions.h (working copy) @@ -33,6 +33,7 @@ #include // for iterator_traits, categories and // _Iter_base #include // for __is_integer +#include // for __addressof and addressof #if __cplusplus >= 201103L # include // for less and greater_equal # include // for common_type @@ -126,8 +127,8 @@ inline bool __valid_range_aux(const _InputIterator& __first, const _InputIterator& __last, std::__false_type) - { return __valid_range_aux2(__first, __last, - std::__iterator_category(__first)); } + { return __valid_range_aux2(__first, __last, + std::__iterator_category(__first)); } /** Don't know what these iterators are, or if they are even * iterators (we may get an integral type for InputIterator), so @@ -182,15 +183,14 @@ { typedef typename std::common_type<_PointerType1, _PointerType2>::type _PointerType; - std::less<_PointerType> __l; - std::greater_equal<_PointerType> __ge; + constexpr std::less<_PointerType> __l; + constexpr std::greater_equal<_PointerType> __ge; - return - __l(std::addressof(*__other), - std::addressof(*(__it._M_get_sequence()->_M_base().begin()))) - || __ge(std::addressof(*__other), - std::addressof(*(__it._M_get_sequence()->_M_base().end() - 1)) + 1); - + return (__l(std::addressof(*__other), + std::addressof(*(__it._M_get_sequence()->_M_base().begin()))) + || __ge(std::addressof(*__other), + std::addressof(*(__it._M_get_sequence()->_M_base().end() + - 1)) + 1)); } template @@ -205,12 +205,13 @@ // past-the-end iterator. if (__it._M_get_sequence()->_M_base().begin() != __it._M_get_sequence()->_M_base().end()) - if (std::__addressof(*(__it._M_get_sequence()->_M_base().end() - 1)) - - std::__addressof(*(__it._M_get_sequence()->_M_base().begin())) + if (std::addressof(*(__it._M_get_sequence()->_M_base().end() - 1)) + - std::addressof(*(__it._M_get_sequence()->_M_base().begin())) == __it._M_get_sequence()->size() - 1) - return __foreign_iterator_aux4(__it, __other, - std::addressof(*(__it._M_get_sequence()->_M_base().begin())), - std::addressof(*__other)); + return (__foreign_iterator_aux4 + (__it, __other, + std::addressof(*(__it._M_get_sequence()->_M_base().begin())), + std::addressof(*__other))); return true; } @@ -232,8 +233,8 @@ { return __it._M_get_sequence() != __other._M_get_sequence(); } #if __cplusplus >= 201103L - /* This overload detects when passing pointers to the contained elements rather - than using iterators. + /* This overload detects when passing pointers to the contained elements + rather than using iterators. */ template inline bool @@ -271,10 +272,9 @@ _InputIterator __other, std::__false_type) { - return - _Insert_range_from_self_is_safe<_Sequence>::__value - || __foreign_iterator_aux2(__it, __other, - std::__iterator_category(__it)); + return (_Insert_range_from_self_is_safe<_Sequence>::__value + || __foreign_iterator_aux2(__it, __other, + std::__iterator_category(__it))); } template() const @@ -277,7 +276,7 @@ _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), _M_message(__msg_bad_deref) ._M_iterator(*this, "this")); - return &*_M_current; + return std::__addressof(*_M_current); } // ------ Input iterator requirements ------ Index: include/debug/safe_local_iterator.h =================================================================== --- include/debug/safe_local_iterator.h (revision 201423) +++ include/debug/safe_local_iterator.h (working copy) @@ -173,7 +173,6 @@ * @brief Iterator dereference. * @pre iterator is dereferenceable * @todo Make this correct w.r.t. iterators that return proxies - * @todo Use addressof() instead of & operator */ pointer operator->() const @@ -181,7 +180,7 @@ _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), _M_message(__msg_bad_deref) ._M_iterator(*this, "this")); - return &*_M_current; + return std::__addressof(*_M_current); } // ------ Input iterator requirements ------ --------------020005030609050700040204--