https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99456
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another thing is that perhaps we should be rejecting reinterpret_cast only in
the
pedantic constant expression evaluation mode, not when we allow extensions and
fold as much as we can. So something like (incremental):
--- gcc/cp/constexpr.c 2021-03-08 13:08:49.944229227 +0100
+++ gcc/cp/constexpr.c 2021-03-08 14:23:01.263716186 +0100
@@ -6629,11 +6629,9 @@
case NOP_EXPR:
case CONVERT_EXPR:
- if (REINTERPRET_CAST_P (t))
+ if (REINTERPRET_CAST_P (t) && !ctx->quiet)
{
- if (!ctx->quiet)
- error_at (loc,
- "%<reinterpret_cast%> is not a constant expression");
+ error_at (loc, "%<reinterpret_cast%> is not a constant expression");
*non_constant_p = true;
return t;
}
@@ -8103,13 +8101,6 @@
case NOP_EXPR:
case CONVERT_EXPR:
- if (REINTERPRET_CAST_P (t))
- {
- if (flags & tf_error)
- error_at (loc, "%<reinterpret_cast%> is not a constant
expression");
- return false;
- }
- /* FALLTHRU */
case VIEW_CONVERT_EXPR:
/* -- a reinterpret_cast. FIXME not implemented, and this rule
may change to something more specific to type-punning (DR 1312). */
But that doesn't make these inline vars statically initialized either, really
confused on what's going on.