public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pkeir at outlook dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113306] New: constexpr cast from void* fails with typeid result target Date: Wed, 10 Jan 2024 11:21:29 +0000 [thread overview] Message-ID: <bug-113306-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113306 Bug ID: 113306 Summary: constexpr cast from void* fails with typeid result target Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pkeir at outlook dot com Target Milestone: --- The C++26 code below fails to compile with GCC trunk; with Clang it passes. The error message indicates that the constexpr evaluator uses `const __fundamental_type_info_pseudo_2` as the type of `typeid(int)`. (See https://godbolt.org/z/1Mr9ao9hr.) #include <typeinfo> #include <cassert> constexpr bool test1() { const void* cvp = &typeid(int); return static_cast<const std::type_info*>(cvp) != nullptr; } int main(int argc, char *argv[]) { static_assert(test1()); assert(test1()); return 0; } The error message is below. bug3.cpp:13:22: in ‘constexpr’ expansion of ‘test1()’ bug3.cpp:8:10: error: cast from ‘const void*’ is not allowed in a constant expression because pointed-to type ‘const __fundamental_type_info_pseudo_2’ is not similar to ‘const std::type_info’ 8 | return static_cast<const std::type_info*>(cvp) != nullptr; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bug3.cpp:6:32: note: pointed-to object declared here 6 | const void* cvp = &typeid(int);
next reply other threads:[~2024-01-10 11:21 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-10 11:21 pkeir at outlook dot com [this message] 2024-01-20 19:35 ` [Bug c++/113306] " pinskia 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-113306-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).