public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "david at doublewise dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99018] Comparing address of array element not considered a constant expression in certain contexts Date: Wed, 10 Mar 2021 22:02:54 +0000 [thread overview] Message-ID: <bug-99018-4-rTNglEtrML@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99018-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99018 --- Comment #2 from David Stone <david at doublewise dot net> --- Simpler test case ``` struct s { constexpr ~s() { } }; constexpr bool f(s const (&)[1]) { return true; } static_assert(f({s()})); ``` Message ``` <source>:10:16: error: non-constant condition for static assertion 10 | static_assert(f({s()})); | ~^~~~~~~ <source>:10:22: error: '(((const s*)(&<anonymous>)) != 0)' is not a constant expression 10 | static_assert(f({s()})); | ^ Compiler returned: 1 ``` See it live: https://godbolt.org/z/YGYjfh You can get the same error by making the function parameter `std::initializer_list<s>` as well. Especially interesting in this reduction is that the code complains about a comparison, but there is no comparison anywhere in the code.
next prev parent reply other threads:[~2021-03-10 22:02 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-09 7:05 [Bug c++/99018] New: " david at doublewise dot net 2021-02-09 20:53 ` [Bug c++/99018] " david at doublewise dot net 2021-03-03 17:34 ` mpolacek at gcc dot gnu.org 2021-03-10 22:02 ` david at doublewise dot net [this message] 2021-08-02 19:05 ` davidfromonline at gmail dot com 2022-01-14 14:02 ` 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-99018-4-rTNglEtrML@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).