public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "eyalroz at technion dot ac.il" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97553] New: [missed optimization] constexprness not noticed when UBsan enabled Date: Fri, 23 Oct 2020 16:27:52 +0000 [thread overview] Message-ID: <bug-97553-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97553 Bug ID: 97553 Summary: [missed optimization] constexprness not noticed when UBsan enabled Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eyalroz at technion dot ac.il Target Milestone: --- (GodBolt example: https://godbolt.org/z/Kvan5c) Consider the following code: #include <string_view> constexpr std::string_view f() { return "hello"; } static constexpr std::string_view g() { auto x { f() }; return x.substr(1, 3); } int foo() { return g().length(); } if you compile it with flags `--std=c++17 -O3`, it results in a pleasant: foo(): mov eax, 3 ret but if you also enabled undefined-behavior sanitization, i.e. `--std=c++17 -fsanitize=undefined -O3`, then you get a much longer program with UB-related instrumentation - which is never used. I'm not sure if it's because some optimizations are disabled with UBsan, in which case this might be a "misfeature", or whether they're enabled but the optimization is just missed.
next reply other threads:[~2020-10-23 16:27 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-23 16:27 eyalroz at technion dot ac.il [this message] 2020-10-23 16:34 ` [Bug c++/97553] " jakub at gcc dot gnu.org 2020-10-26 16:50 ` mpolacek at gcc dot gnu.org 2020-10-26 19:40 ` eyalroz at technion dot ac.il 2020-10-26 19:45 ` jakub at gcc dot gnu.org 2020-10-26 20:46 ` eyalroz at technion dot ac.il 2023-02-17 20:21 ` cvs-commit at gcc dot gnu.org 2023-03-02 19:05 ` cvs-commit at gcc dot gnu.org 2023-04-26 13:18 ` ppalka 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-97553-4@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).