public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113713] static_assert result depends on optimization settings Date: Fri, 02 Feb 2024 08:28:15 +0000 [thread overview] Message-ID: <bug-113713-4-GEe23dWd33@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113713-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113713 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2024-02-02 Status|UNCONFIRMED |NEW --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed, this is a constexpr issue in both clang and GCC (unless there is some unspecified behavior I don't know of). Take: ``` #if defined(CE) #define CONSTEXPR constexpr #else #define CONSTEXPR #endif struct A{}; template<class T> CONSTEXPR bool p(T) { return false; } template<class T> CONSTEXPR bool f(T v) { return p(v); } CONSTEXPR bool g() { return f(A()); } CONSTEXPR bool p(A) { return true; } int main() { A a; if (!f(a)) __builtin_abort(); } ``` Without CE being defined, this works at all optimizations level. With CE being defined this works at -O0 only (like there is some [incorrect?] caching going on at -O1 and above and clang is doing the caching at all levels).
next prev parent reply other threads:[~2024-02-02 8:28 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-02 8:08 [Bug c++/113713] New: " fchelnokov at gmail dot com 2024-02-02 8:17 ` [Bug c++/113713] " pinskia at gcc dot gnu.org 2024-02-02 8:28 ` pinskia at gcc dot gnu.org [this message] 2024-02-02 8:34 ` [Bug c++/113713] constexpr function values (incorrectly?) depend on optimization level pinskia at gcc dot gnu.org 2024-02-02 15:11 ` mpolacek 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-113713-4-GEe23dWd33@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).