From patchwork Tue Nov 21 16:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 167858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp796131vqb; Tue, 21 Nov 2023 09:36:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMI7BAvlZC1JuDAROV4h8Qjd6n24KJlexGrfuFWnTWFqP7n3LBJJAcJX3YPxeOcwysyGR9 X-Received: by 2002:ac8:5684:0:b0:423:6e1e:d517 with SMTP id h4-20020ac85684000000b004236e1ed517mr3063542qta.59.1700588219110; Tue, 21 Nov 2023 09:36:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700588219; cv=pass; d=google.com; s=arc-20160816; b=WjG6s5z7IDaHeiZJWd8ZBiGxv6Oimq6XzdNxEGf8wHPgikUzfYgqRI5pKfv9zGVdFw saKCodYrkgeldMkaFbSfaSlEBJFJcH8eGJ9yHjUDly1BkujaMbuN1w1rArgXVzX9cVLj WseoGUy0AIToq7o41d2muMN3jFhXqLaQO47C67y40PoEepwehO+LxSfKvKvQ+Xg07ZeT NsEaSwP9yFAOx4GTdPsPIDZqVlZEUbLOdkiFstGxKGPkvuPGGbeWzHKRs2SZz4nulHN3 wMOMD5xe6EBvUJtEn/JqdfdSW3FZsJ2pgbNoNJLQnvbbfZ1rFozDvIU9fllbjQEcy1sW x45w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ISeDDmPjESxCamYngM1DwE6/Rx6fPWWFFuQx83s/EdQ=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=V9IwP5kwhN/Xs3xoQ3nZfvPm2j7i6BCWuRn0KHEACNpFL55W+u+sPYX2maWeU/jmtH Y4bu3ogGAAqWgjIpjLJFsHFYqtKcrhmtCjNasGhYCOeW86jYtBIzl1B0YSpKS/fCpgrm wboI4ZYtzxu9XndEMTL4H0nje1W+Kbd6BjNy6Q8yjJXUxkj4+Vt1O2nl85MqdtrdYVrM rA3VhiQ09pCA7Or+86GNL9AbU/iuCPt5Tojk/Br4jfi6iMk5hiFy/TRpRxOnv3J8xPJL ZM8HCjlc/iFYKjhw1bgGJgHAayfQTpbBSbKV7sbEbQq9jpDyoDmzvJlYZQy4xnQqt9sr xboA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EkQxNPxY; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id p16-20020a05622a13d000b00421c99688besi9682743qtk.640.2023.11.21.09.36.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 09:36:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EkQxNPxY; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA32C3857C56 for ; Tue, 21 Nov 2023 16:09:31 +0000 (GMT) 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 533763858CDA for ; Tue, 21 Nov 2023 16:08:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 533763858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 533763858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700582932; cv=none; b=ZAxLQxzDQ7LncHhdEAzN0yfDbeJiEFIavsw70M/Hzqklc51uofuHdf1ZpkaI7iTALj85GGvbvmsuMvPwUK/KxgLEUDPdi5P8qMGV5+gI/Vg4YuZDsDRwk2cqYhfinXDmwuglLeXJqD9vFJgoqQFLI5SPENwJ/wTj5v3IaPQMF3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700582932; c=relaxed/simple; bh=dLfED0GtI9ZWT3UzrsQ/bpSd8QnORr5KHpkA2KAaE3U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CxgUa0iQu+Tqzj+FWwYlcSVotY/84DPZ89e4Y/vL4Mbw0JdulaD49equDGIYjtbEaMhP4PGjgsI3AF8rVOk4cWmvEKqdisd7JjedLHDbX7TBSgTZImO4ePrJQXAomEG4R5aAG08pbO55s3WsXUEjGYjRYRIxdXUbDugkNy9XISs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700582930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ISeDDmPjESxCamYngM1DwE6/Rx6fPWWFFuQx83s/EdQ=; b=EkQxNPxY1FCIM57Nvt82JqqIEJHKknIRkr/hbqn489vkIcJrveX3EQxVF/om1j9Foac6wB ewFHy8LFgEc2MpkeM2Q2FH8bRvY8XJwXFdObqHQ1efuw2iBrtP45Ymc3utUj8Gdstraqp0 rJO4pBlTEMKg8Gnm1tvCpk17+rNrNxo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-401-bY5MygSBOluvDApImNW56w-1; Tue, 21 Nov 2023 11:08:47 -0500 X-MC-Unique: bY5MygSBOluvDApImNW56w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E35C11C07563; Tue, 21 Nov 2023 16:08:46 +0000 (UTC) Received: from localhost (unknown [10.42.28.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id A215C492BE0; Tue, 21 Nov 2023 16:08:46 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix std::tr2::dynamic_bitset support for alternate characters Date: Tue, 21 Nov 2023 16:08:14 +0000 Message-ID: <20231121160845.2030365-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783195992716549402 X-GMAIL-MSGID: 1783195992716549402 Tested x86_64-linux. Pushed to trunk. Backports to follow. -- >8 -- libstdc++-v3/ChangeLog: * include/tr2/dynamic_bitset (dynamic_bitset): Pass zero and one characters to _M_copy_from_string. * testsuite/tr2/dynamic_bitset/string.cc: New test. --- libstdc++-v3/include/tr2/dynamic_bitset | 2 +- .../testsuite/tr2/dynamic_bitset/string.cc | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc diff --git a/libstdc++-v3/include/tr2/dynamic_bitset b/libstdc++-v3/include/tr2/dynamic_bitset index dd2845bd26b..ffdce82590f 100644 --- a/libstdc++-v3/include/tr2/dynamic_bitset +++ b/libstdc++-v3/include/tr2/dynamic_bitset @@ -622,7 +622,7 @@ namespace tr2 // Watch for npos. this->_M_Nb = (__n > __str.size() ? __str.size() - __pos : __n); this->resize(this->_M_Nb); - this->_M_copy_from_string(__str, __pos, __n); + this->_M_copy_from_string(__str, __pos, __n, __zero, __one); } /** diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc b/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc new file mode 100644 index 00000000000..c7d0efac35f --- /dev/null +++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc @@ -0,0 +1,36 @@ +// { dg-do run { target c++11 } } + +#include +#include +#include + +void +test_string_ctor() +{ + std::tr2::dynamic_bitset<> b("101001"); + VERIFY( b[0] == true ); + VERIFY( b[1] == false ); + VERIFY( b[2] == false ); + VERIFY( b[3] == true ); + VERIFY( b[4] == false ); + VERIFY( b[5] == true ); +} + +void +test_alt_chars() +{ + std::string str = "xOIOIOIOx"; + std::tr2::dynamic_bitset<> b(str, 1, 6, 'I', 'O'); + VERIFY( b[0] == false ); + VERIFY( b[1] == true ); + VERIFY( b[2] == false ); + VERIFY( b[3] == true ); + VERIFY( b[4] == false ); + VERIFY( b[5] == true ); +} + +int main() +{ + test_string_ctor(); + test_alt_chars(); +}