public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/86369] constexpr const char* comparison fails Date: Thu, 05 Aug 2021 18:09:16 +0000 [thread overview] Message-ID: <bug-86369-4-4k6HxpgHvH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-86369-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86369 --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Another possibility would be to detect it in cxx_eval_binary_expression before calling fold_binary_loc and punt. But, the constant evaluation actually doesn't track whether it is the same or different evaluation of the same string literal, so not optimizing it would on the other side mean we'd reject valid code. Consider constexpr auto name3(const char *p) { return p; } int main() { constexpr auto p1 = "test3"; constexpr auto p2 = "test4"; constexpr auto b1 = (name3(p1) == name3(p1)); // should be true constexpr auto b2 = (name3(p1) == name3(p2)); // should be false } Note, latest clang++ seems to accept b1 in both #c0 and #c6 testcases and reject b2 in both.
next prev parent reply other threads:[~2021-08-05 18:09 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-86369-4@http.gcc.gnu.org/bugzilla/> 2021-08-05 4:43 ` pinskia at gcc dot gnu.org 2021-08-05 15:24 ` redi at gcc dot gnu.org 2021-08-05 15:30 ` jakub at gcc dot gnu.org 2021-08-05 18:09 ` jakub at gcc dot gnu.org [this message] 2021-08-06 7:27 ` rguenth at gcc dot gnu.org 2022-01-18 13:18 ` jason at gcc dot gnu.org 2022-11-04 13:10 ` aaron at aaronballman dot com 2022-11-04 13:27 ` jakub at gcc dot gnu.org 2022-11-04 13:53 ` aaron at aaronballman dot com
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-86369-4-4k6HxpgHvH@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).