public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bluescarni at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94716] New: Address of constexpr variable not usable in constant expression Date: Wed, 22 Apr 2020 15:36:57 +0000 [thread overview] Message-ID: <bug-94716-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94716 Bug ID: 94716 Summary: Address of constexpr variable not usable in constant expression Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bluescarni at gmail dot com Target Milestone: --- The following code does not compile in GCC trunk: ----- template <typename T> inline constexpr char test_impl = 0; template <typename T> inline constexpr auto *id = &test_impl<T>; int main() { static_assert(id<int> != id<float>, "should not be equal"); } ----- The error message: ----- <source>: In function 'int main()': <source>:8:27: error: non-constant condition for static assertion 8 | static_assert(id<int> != id<float>, "should not be equal"); | ~~~~~~~~^~~~~~~~~~~~ <source>:8:27: error: '((& test_impl<int>) != (& test_impl<float>))' is not a constant expression Compiler returned: 1 ----- See on godbolt: https://godbolt.org/z/CS4D8B Clang and MSVC accept the code.
next reply other threads:[~2020-04-22 15:36 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-22 15:36 bluescarni at gmail dot com [this message] 2020-04-23 5:14 ` [Bug c++/94716] " marxin at gcc dot gnu.org 2021-08-28 22:27 ` [Bug c++/94716] comparison of address of template variables should be constexpr pinskia at gcc dot gnu.org 2021-09-10 22:46 ` johelegp at gmail dot com 2021-12-28 10:40 ` pinskia at gcc dot gnu.org 2022-01-03 12:48 ` cvs-commit at gcc dot gnu.org 2022-01-04 19:15 ` ppalka at gcc dot gnu.org 2022-01-06 16:17 ` 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-94716-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).