From patchwork Sun Nov 7 15:15:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 70351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BEA76B70F9 for ; Mon, 8 Nov 2010 02:16:19 +1100 (EST) Received: (qmail 18330 invoked by alias); 7 Nov 2010 15:16:10 -0000 Received: (qmail 18307 invoked by uid 22791); 7 Nov 2010 15:16:06 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from vsmtp4.tin.it (HELO vsmtp4.tin.it) (212.216.176.224) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 07 Nov 2010 15:15:57 +0000 Received: from [192.168.0.4] (79.25.196.7) by vsmtp4.tin.it (8.5.113) id 4BCE3CBE0ECC4973; Sun, 7 Nov 2010 16:15:54 +0100 Message-ID: <4CD6C29F.9090502@oracle.com> Date: Sun, 07 Nov 2010 16:15:43 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101026 SUSE/3.0.10 Thunderbird/3.0.10 MIME-Version: 1.0 To: libstdc++ CC: "gcc-patches@gcc.gnu.org" Subject: [v3] Fix debug-mode std::bitset vs constexpr X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, testing debug-mode revealed a pretty serious issue in the form of two compile-time fails: since _Safe_sequence_base has a non trivial-destructor (and possibly for other reasons too, I didn't investigate in detail yet), deriving from it caused std::bitset to not be a literal type anymore. For now I'm just suppressing the derivation, thus disabling some debug-mode checks in C++0x mode (to be honest there aren't so many, anyway), better solutions welcome of course. Tested x86_64-linux, committed to mainline. Paolo. ///////////////////// 2010-11-07 Paolo Carlini * include/debug/bitset: Do not derive from _Safe_sequence_base in C++0x mode, otherwise std::bitset isn't a literal type anymore; adjust everywhere. * include/debug/bitset (bitset<>::bitset(), bitset<>:: bitset(unsigned long long)): Add missing constexpr specifier. Index: include/debug/bitset =================================================================== --- include/debug/bitset (revision 166414) +++ include/debug/bitset (working copy) @@ -41,37 +41,50 @@ /// Class std::bitset with additional safety/checking/debug instrumentation. template class bitset - : public _GLIBCXX_STD_D::bitset<_Nb>, - public __gnu_debug::_Safe_sequence_base + : public _GLIBCXX_STD_D::bitset<_Nb> +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + , public __gnu_debug::_Safe_sequence_base +#endif { typedef _GLIBCXX_STD_D::bitset<_Nb> _Base; - typedef __gnu_debug::_Safe_sequence_base _Safe_base; public: // bit reference: class reference - : private _Base::reference, public __gnu_debug::_Safe_iterator_base + : private _Base::reference +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + , public __gnu_debug::_Safe_iterator_base +#endif { typedef typename _Base::reference _Base_ref; friend class bitset; reference(); - reference(const _Base_ref& __base, bitset* __seq) - : _Base_ref(__base), _Safe_iterator_base(__seq, false) + reference(const _Base_ref& __base, + bitset* __seq __attribute__((__unused__))) + : _Base_ref(__base) +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + , _Safe_iterator_base(__seq, false) +#endif { } public: reference(const reference& __x) - : _Base_ref(__x), _Safe_iterator_base(__x, false) + : _Base_ref(__x) +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + , _Safe_iterator_base(__x, false) +#endif { } reference& operator=(bool __x) { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); +#endif *static_cast<_Base_ref*>(this) = __x; return *this; } @@ -79,12 +92,14 @@ reference& operator=(const reference& __x) { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(__x)); _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); +#endif *static_cast<_Base_ref*>(this) = __x; return *this; } @@ -92,36 +107,42 @@ bool operator~() const { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); +#endif return ~(*static_cast(this)); } operator bool() const { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); +#endif return *static_cast(this); } reference& flip() { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_flip) ._M_iterator(*this)); +#endif _Base_ref::flip(); return *this; } }; // 23.3.5.1 constructors: - bitset() : _Base() { } + _GLIBCXX_CONSTEXPR bitset() : _Base() { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ - bitset(unsigned long long __val) + constexpr bitset(unsigned long long __val) #else bitset(unsigned long __val) #endif @@ -147,7 +168,7 @@ _CharT __zero, _CharT __one = _CharT('1')) : _Base(__str, __pos, __n, __zero, __one) { } - bitset(const _Base& __x) : _Base(__x), _Safe_base() { } + bitset(const _Base& __x) : _Base(__x) { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ template