From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id D60C03857369; Thu, 21 Apr 2022 10:34:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D60C03857369 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-8213] libstdc++: Remove bogus assertion in std::from_chars [PR105324] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 811c7fbd147991645e6116897f07d8a406b864e6 X-Git-Newrev: cf37107522f465d9e12af01ba68d2d1df0f18d46 Message-Id: <20220421103438.D60C03857369@sourceware.org> Date: Thu, 21 Apr 2022 10:34:38 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 10:34:39 -0000 https://gcc.gnu.org/g:cf37107522f465d9e12af01ba68d2d1df0f18d46 commit r12-8213-gcf37107522f465d9e12af01ba68d2d1df0f18d46 Author: Jonathan Wakely Date: Thu Apr 21 11:26:49 2022 +0100 libstdc++: Remove bogus assertion in std::from_chars [PR105324] 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. Diff: --- libstdc++-v3/src/c++17/floating_from_chars.cc | 1 - libstdc++-v3/testsuite/20_util/from_chars/pr105324.cc | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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); +}