public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113306] New: constexpr cast from void* fails with typeid result target
@ 2024-01-10 11:21 pkeir at outlook dot com
2024-01-20 19:35 ` [Bug c++/113306] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: pkeir at outlook dot com @ 2024-01-10 11:21 UTC (permalink / raw)
To: gcc-bugs
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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/113306] constexpr cast from void* fails with typeid result target
2024-01-10 11:21 [Bug c++/113306] New: constexpr cast from void* fails with typeid result target pkeir at outlook dot com
@ 2024-01-20 19:35 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-20 19:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113306
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2024-01-20
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-20 19:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 11:21 [Bug c++/113306] New: constexpr cast from void* fails with typeid result target pkeir at outlook dot com
2024-01-20 19:35 ` [Bug c++/113306] " pinskia at gcc dot gnu.org
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).