public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/99181] char_traits<char> (and thus string_view) compares strings differently in constexpr and non-constexpr contexts Date: Tue, 23 Feb 2021 08:37:43 +0000 [thread overview] Message-ID: <bug-99181-4-2pLy2htM1x@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99181-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99181 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:efa64fcce12074dd542670feb02eaee53e810a30 commit r11-7340-gefa64fcce12074dd542670feb02eaee53e810a30 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Feb 23 09:30:18 2021 +0100 libstdc++: Fix up constexpr std::char_traits<char>::compare [PR99181] Because of LWG 467, std::char_traits<char>::lt compares the values cast to unsigned char rather than char, so even when char is signed we get unsigned comparision. std::char_traits<char>::compare uses __builtin_memcmp and that works the same, but during constexpr evaluation we were calling __gnu_cxx::char_traits<char_type>::compare. As char_traits::lt is not virtual, __gnu_cxx::char_traits<char_type>::compare used __gnu_cxx::char_traits<char_type>::lt rather than std::char_traits<char>::lt and thus compared chars as signed if char is signed. This change fixes it by inlining __gnu_cxx::char_traits<char_type>::compare into std::char_traits<char>::compare by hand, so that it calls the right lt method. 2021-02-23 Jakub Jelinek <jakub@redhat.com> PR libstdc++/99181 * include/bits/char_traits.h (char_traits<char>::compare): For constexpr evaluation don't call __gnu_cxx::char_traits<char_type>::compare but do the comparison loop directly. * testsuite/21_strings/char_traits/requirements/char/99181.cc: New test.
next prev parent reply other threads:[~2021-02-23 8:37 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-20 15:47 [Bug libstdc++/99181] New: " richardpku at gmail dot com 2021-02-22 9:43 ` [Bug libstdc++/99181] " jakub at gcc dot gnu.org 2021-02-22 14:27 ` jakub at gcc dot gnu.org 2021-02-22 14:42 ` redi at gcc dot gnu.org 2021-02-23 8:37 ` cvs-commit at gcc dot gnu.org [this message] 2021-02-23 9:12 ` jakub at gcc dot gnu.org 2021-02-23 10:46 ` redi at gcc dot gnu.org 2021-03-19 23:29 ` cvs-commit at gcc dot gnu.org 2021-04-20 23:32 ` cvs-commit at gcc dot gnu.org 2021-04-22 16:51 ` cvs-commit at gcc dot gnu.org 2021-04-22 17:11 ` jakub at gcc dot gnu.org 2021-09-11 14:23 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-99181-4-2pLy2htM1x@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).