From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E4CFE3858C31; Sat, 6 Jan 2024 13:40:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4CFE3858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704548404; bh=6AOmr5IyXjAR/sXbcZIdLFcytudGUKY8FaH+xmEZak0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VR+KSL++dCnbthKscclkup0BDHd+WG+UCHiflKgBPY5uLMdxyPBE5hCUMO8t1ZDu+ RY25LjMuQ6KmpjMXP9oZCqd+/mgIo5ce3K+E6XbTySPjDkAqPnhPCRTB7uN1j0u5Gw wdsTZxBjBdTaHk8d3AZwKSkE6gixWECegpxzkIcY= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113200] std::char_traits::move is not constexpr when the argument is a string literal Date: Sat, 06 Jan 2024 13:40:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113200 --- Comment #11 from GCC Commits --- The releases/gcc-13 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:22601c1c25652c71c8bab4707866c020d6dad79a commit r13-8193-g22601c1c25652c71c8bab4707866c020d6dad79a Author: Jonathan Wakely Date: Wed Jan 3 15:01:09 2024 +0000 libstdc++: Fix std::char_traits::move [PR113200] The current constexpr implementation of std::char_traits::move relies on being able to compare the pointer parameters, which is not allowed for unrelated pointers. We can use __builtin_constant_p to determine whether it's safe to compare the pointers directly. If not, then we know the ranges must be disjoint and so we can use char_traits::copy to copy forwards from the first character to the last. If the pointers can be compared directly, then we can simplify the condition for copying backwards to just two pointer comparisons. libstdc++-v3/ChangeLog: PR libstdc++/113200 * include/bits/char_traits.h (__gnu_cxx::char_traits::move): Use __builtin_constant_p to check for unrelated pointers that cannot be compared during constant evaluation. * testsuite/21_strings/char_traits/requirements/113200.cc: New test. (cherry picked from commit 15cc291887dc9dd92b2c93f4545e20eb6c190122)=