From patchwork Mon Sep 26 12:59:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1465 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1476639wrt; Mon, 26 Sep 2022 06:01:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6n93Qmuk0wB/B8hKYHjUe+EbXG0euCVUZX1uICVmH4JUgutj/mCkoEQV7FgIHujwl3mgAm X-Received: by 2002:aa7:cd92:0:b0:456:cbb5:2027 with SMTP id x18-20020aa7cd92000000b00456cbb52027mr16163996edv.384.1664197271963; Mon, 26 Sep 2022 06:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664197271; cv=none; d=google.com; s=arc-20160816; b=dBzPhnGpcBIr/97QCqY1zepUFV8yv10Bh5i7Z1X+m5YQPV4IEOp29LurCLY6dRj8/0 1+pt2mDf3GcCKc4Svdi63s802we5yk+FHhDhDEG9eq3QnKedWXh7o/UQ/Wj0kBK3za2D GNdPEvmm6HMu6jNDI2LiGCnzlmFUBGGcGiJPjWQhoC7q4O3g4Kz4QU2TfQjw0wC9pSgY zD/jPocMhU/sExKM023N9QaEb3NESS7OCng5BTvGPWy2qyepsw0s2bo1g9WvhVEiOPYW nbyjTzEwd0Hd0Z7Wt2W0PQBcSv7eVT91lvfFD5Fh8tyIATICxiC/7kz38QoqX9gj9BEv iX5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=vqtRbVdbRPa7AawGjgpD9s/UKNObMrlkz92+16/F6G0=; b=mnwyJObKf5xKWDWBqg6XVgnbgSO8w9N2VcSwA6U/3HBCn9etngUOCWSlnpFBgzybJx it8pSuYDPoxiGInn9ayuJVIPCfXrpcrLBJki6I8trp463nXURHnjxABg34j+uw7e/IMH z1EfVda1iKsv1AdxfCGzycdyjsHESODCQja4hZmYypUvg6ArKj1rRIXmlhoeK8is6l7A z7lgVc6pTFD+OA1iu+rvndowfShvIWrjztZVc6Si0z0E4bV84Yq0s+CGC4sHq89KGBCy 8LYzVNd1mnIYjiDcKZLTEy9RcvMWUH8T7nit1LNM6rWoNvNmwlR9D3/M1acT3MZ4Nj6E mfAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uiGNH7ue; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n15-20020a056402060f00b00445dfc9c0cdsi1289706edv.122.2022.09.26.06.01.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 06:01:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uiGNH7ue; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09FB33857BBB for ; Mon, 26 Sep 2022 13:00:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09FB33857BBB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664197243; bh=vqtRbVdbRPa7AawGjgpD9s/UKNObMrlkz92+16/F6G0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uiGNH7uehlybjmI6dGHjMTqYttSnfDL4YoaKP0CcGNGKD1rBBZLsEA/7gTvSy6uIJ Kz0+Uy15tdcxGtTdST9t8/HN0b6JU4H2cPVnwz6xwqKiMgagZd+nO1OG5Ww1ewEm97 54z43R5+uPVzx7FuJ/QWOzMUmhq5v0Y4a9EHVGCo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 0315D3858C74 for ; Mon, 26 Sep 2022 12:59:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0315D3858C74 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-537-IUBzy4GCMtOi4CMC6LVy8g-1; Mon, 26 Sep 2022 08:59:55 -0400 X-MC-Unique: IUBzy4GCMtOi4CMC6LVy8g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5C30185A794; Mon, 26 Sep 2022 12:59:54 +0000 (UTC) Received: from localhost (unknown [10.33.36.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D14617583; Mon, 26 Sep 2022 12:59:54 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add #if around non-C++03 code in std::bitset [PR107037] Date: Mon, 26 Sep 2022 13:59:53 +0100 Message-Id: <20220926125953.2149422-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, URI_HEX autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745037318671470412?= X-GMAIL-MSGID: =?utf-8?q?1745037318671470412?= Tested x86_64-linux, pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: PR libstdc++/107037 * include/std/bitset (_Base_bitset::_M_do_reset): Use preprocessor conditional around non-C++03 code. * testsuite/20_util/bitset/107037.cc: New test. --- libstdc++-v3/include/std/bitset | 5 +++-- libstdc++-v3/testsuite/20_util/bitset/107037.cc | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/bitset/107037.cc diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset index 6dbc58c6429..1a551cf9785 100644 --- a/libstdc++-v3/include/std/bitset +++ b/libstdc++-v3/include/std/bitset @@ -182,13 +182,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX14_CONSTEXPR void _M_do_reset() _GLIBCXX_NOEXCEPT { +#if __cplusplus >= 201402L if (__builtin_is_constant_evaluated()) { for (_WordT& __w : _M_w) __w = 0; return; } - +#endif __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); } @@ -1680,7 +1681,7 @@ _GLIBCXX_END_NAMESPACE_VERSION #endif // C++11 -#ifdef _GLIBCXX_DEBUG && _GLIBCXX_HOSTED +#if defined _GLIBCXX_DEBUG && _GLIBCXX_HOSTED # include #endif diff --git a/libstdc++-v3/testsuite/20_util/bitset/107037.cc b/libstdc++-v3/testsuite/20_util/bitset/107037.cc new file mode 100644 index 00000000000..b4560dd3775 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/107037.cc @@ -0,0 +1,7 @@ +// { dg-options "-std=c++03" } +// { dg-do compile } +// PR libstdc++/107037 bitset::_M_do_reset fails for strict -std=c++03 mode +#include +template class std::bitset<0>; +template class std::bitset<1>; +template class std::bitset<100>;