From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 622013857C4D; Wed, 5 Jan 2022 22:07:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 622013857C4D From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/89074] valid pointer equality constexpr comparison rejected Date: Wed, 05 Jan 2022 22:07:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 9.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: --- 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jan 2022 22:07:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D89074 --- Comment #13 from CVS Commits --- The releases/gcc-11 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:226210894e53259940a8e1453125e37c65299ba4 commit r11-9441-g226210894e53259940a8e1453125e37c65299ba4 Author: Jonathan Wakely Date: Thu Nov 18 12:39:20 2021 +0000 libstdc++: Fix std::char_traits::move for constexpr The constexpr branch in __gnu_cxx::char_traits::move compares the string arguments to see if they overlap, but relational comparisons between unrelated pointers are not core constant expressions. I want to replace the comparisons with a loop using pointer equality to determine whether the end of the source string is in the destination string. However, that doesn't work with GCC, due to PR c++/89074 so allocate a temporary buffer instead and copy out into that first, so that overlapping source and destination don't matter. The allocation isn't supported by the current Intel icc so use the loop as a fallback. libstdc++-v3/ChangeLog: * include/bits/char_traits.h (__gnu_cxx::char_traits::move): Do not compare unrelated pointers during constant evaluation. * testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc: Improve tests for char_traits::move. (cherry picked from commit ca243ada71656651a8753e88164a1f0f019be1c3)=