From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 BC7223856DD5 for ; Thu, 21 Apr 2022 10:35:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC7223856DD5 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611-pNpQNFbEPUeZgyOiiNuegg-1; Thu, 21 Apr 2022 06:35:03 -0400 X-MC-Unique: pNpQNFbEPUeZgyOiiNuegg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CED513C1618A; Thu, 21 Apr 2022 10:35:02 +0000 (UTC) Received: from localhost (unknown [10.33.36.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9487640CFD1E; Thu, 21 Apr 2022 10:35:02 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Remove bogus assertion in std::from_chars [PR105324] Date: Thu, 21 Apr 2022 11:35:01 +0100 Message-Id: <20220421103501.1530890-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.0 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, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 10:35:08 -0000 Tested x86_64-linux, pushed to trunk. Backport to gcc-11 to follow. -- >8 -- I'm not sure what I was thinking when I added this assertion, maybe it was supposed to be alignment == 1 (which is what the pmr::string actually uses). The simplest fix is to just remove the assertion. The assertion is no longer enabled by default on trunk, but it's still there for the --enablke-libstdcxx-debug build, and is still wrong. The fix is needed on the gcc-11 branch. libstdc++-v3/ChangeLog: PR libstdc++/105324 * src/c++17/floating_from_chars.cc (buffer_resource::do_allocate): Remove assertion. * testsuite/20_util/from_chars/pr105324.cc: New test. --- libstdc++-v3/src/c++17/floating_from_chars.cc | 1 - .../testsuite/20_util/from_chars/pr105324.cc | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc b/libstdc++-v3/src/c++17/floating_from_chars.cc index bbe03f7f068..0f5183aa9b5 100644 --- a/libstdc++-v3/src/c++17/floating_from_chars.cc +++ b/libstdc++-v3/src/c++17/floating_from_chars.cc @@ -101,7 +101,6 @@ namespace return m_buf + std::__exchange(m_bytes, m_bytes + bytes); __glibcxx_assert(m_ptr == nullptr); - __glibcxx_assert(alignment != 1); m_ptr = operator new(bytes); m_bytes = bytes; diff --git a/libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc b/libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc new file mode 100644 index 00000000000..cecb17e41cc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc @@ -0,0 +1,14 @@ +// { dg-do run { target c++17 } } + +#include +#include + +int main() +{ + // PR libstdc++/105324 + // std::from_chars() assertion at floating_from_chars.cc:78 + std::string s(512, '1'); + s[1] = '.'; + long double d; + std::from_chars(s.data(), s.data() + s.size(), d); +} -- 2.34.1