From patchwork Wed Sep 24 22:18:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 393125 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 87DB01400B7 for ; Thu, 25 Sep 2014 08:18:35 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=qIRUkBdIz6zSlXjdv7hK82gV7O1DZKpJuDQZLK6u9EOdGX0Lk0PY5 X79qdz7WCagzFT38Q7r15zoK8FsGoAlvHboF6i+bdetnHNwNb8UeC+SXX4I4rXan OnjTMuZR0XzrCE8K19dehQ8B5g/Nv6No/IaJkC0vxTKvNbxocZbA+Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=lw6LPwTgaj2peVIp1Sf00g/21y8=; b=BHtHNlrbzaCk9SSLdSvw CBXhYsGPswKjKNMuUVVM8rkbOZfZ/Z+WEtUZaOv48T2UZP+D6zJLrc0FtU/9pPWs D0xrECz4I8QpjQC3r21j6OKg0XhrN7doQEvB42cz+rrWA4Qm+mornIMYlrmJwpN/ 5yFdyqREDwDzwqnEyXJxVb8= Received: (qmail 780 invoked by alias); 24 Sep 2014 22:18:20 -0000 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 Received: (qmail 762 invoked by uid 89); 24 Sep 2014 22:18:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 24 Sep 2014 22:18:19 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8OMIGtu001862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 24 Sep 2014 18:18:17 -0400 Received: from localhost (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8OMIFuR020876; Wed, 24 Sep 2014 18:18:16 -0400 Date: Wed, 24 Sep 2014 23:18:15 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [patch] libstdc++/56193 re-add basic_ios::operator bool() Message-ID: <20140924221814.GZ2669@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This changes operator void*() to operator bool(), and ensures we export both from the library. I have a new test for this, but will commit that tomorrow. Tested x86_64-linux, committed to trunk. commit 65eba18bbe122c7e274a81aace7e7290645245c8 Author: redi Date: Wed Sep 24 22:13:35 2014 +0000 PR libstdc++/56193 * config/abi/pre/gnu.ver: Add new exports. * include/bits/basic_ios.h (basic_ios::operator bool): Define. * src/c++98/ios_locale.cc (basic_ios::operator void*): Instantiate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215571 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 63985fd..0559444 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -1470,6 +1470,9 @@ GLIBCXX_3.4.21 { _ZNSoC[12]ERSd; _ZNSt13basic_ostreamIwSt11char_traitsIwEEC[12]ERSt14basic_iostreamIwS1_E; + # std::basic_ios::operator bool() const + _ZNKSt9basic_iosI[cw]St11char_traitsI[cw]EEcvbEv; + } GLIBCXX_3.4.20; diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/include/bits/basic_ios.h index 10263ed..0a83d0d 100644 --- a/libstdc++-v3/include/bits/basic_ios.h +++ b/libstdc++-v3/include/bits/basic_ios.h @@ -113,8 +113,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * This allows you to write constructs such as * if (!a_stream) ... and while (a_stream) ... */ +#if __cplusplus >= 201103L + explicit operator bool() const + { return !this->fail(); } +#else operator void*() const { return this->fail() ? 0 : const_cast(this); } +#endif bool operator!() const diff --git a/libstdc++-v3/src/c++98/ios_locale.cc b/libstdc++-v3/src/c++98/ios_locale.cc index fd2e9e4..968af98 100644 --- a/libstdc++-v3/src/c++98/ios_locale.cc +++ b/libstdc++-v3/src/c++98/ios_locale.cc @@ -54,5 +54,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __old; } + // Explicit instantiations for basic_ios are done in src/c++11/ios.cc + // and so do not include this member, which is only defined for C++98. + template basic_ios::operator void*() const; +#ifdef _GLIBCXX_USE_WCHAR_T + template basic_ios::operator void*() const; +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace