On 12/11/18 11:34 AM, Jakub Jelinek wrote:
Hi!

While working on the libstdc++ patch for P0595R2, I've noticed that while
__builtin_is_constant_evaluated () directly works, when wrapped into
an constexpr inline noexcept function, it in some cases doesn't.  The
problem is that the constexpr call cache didn't take
ctx->pretend_const_required into account.

The following patch fixes it by just treating it like another magic
parameter.  Another option would be (but much more involved) to remember
during the constexpr.c processing whether we've seen during the evaluation
any calls to __builtin_is_constant_evaluated (that would require propagating
in all the spots that use a new context back to the old context).  Then
we could in the constexpr hash remember either that during the evaluation
of that constexpr call there was no __builtin_is_constant_evaluated seen,
or, if it has been seen, whether it was in ctx->pretend_const_required
mode or in !ctx->pretend_const_required mode.

I've bootstrapped/regtested on x86_64-linux and i686-linux the following
simpler version, ok for trunk?

OK.

Jason

Reply via email to