https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86590

--- Comment #24 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I wonder if instead of the list they provide they really didn't mean all the
spots in the standard that actually require constant-expression (I guess too
hard to list them all again in one place; furthermore, e.g. various language
extensions like OpenMP etc. also require constant expressions in further
places;
anyway, I think this category is where gcc does constexpr.c evaluation with
!ctx->quiet), plus that extra special case of initializer of
"a variable of reference type or of non-volatile const-qualified integral or
enumeration type or of non-automatic storage duration"
where if in that initializer std::is_constant_evaluated () were to evaluate to
true, then the result would be a constant expression.  In order to implement
this
behavior, the above patch would instead of that 0 && ctx->quiet be
ctx->quiet && !ctx->in_certain_initializer and when trying to evaluate the
initializers of those above mentioned variables we'd make sure that flag is
set.
If that would return a constant expression, we'd use that, now not really sure
if we then should just use another maybe_constant_value or similar that would
evaluate it again without that special new flag (and what to do with caching),
or if it would be ok to leave those as is.

Modifying the above patch just to remove that "0 && " part and renaming that
builtin to something different, so it would be clearly unrelated to whatever
is_constant_evaluated becomes and would only be true in spots that are required
to be constant expressions (i.e. !ctx->quiet) might be a usable temporary
solution for this issue, if the C++ maintainer would be willing to accept that.

In any case, as mentioned in another PR, static_assert seems to require a
constant-expression, so I wonder if we don't need to change that to evaluate
the expression with !ctx->quiet.

Reply via email to