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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
As
consteval bool
foo (bool x)
{
  return x;
}

constexpr bool
bar ()
{
  if consteval
    {
      return true;
    }
  else
    {
      return false;
    }
}

int
main ()
{
  bool a = false;
  a = foo (bar ());
  if (!a)
    __builtin_abort ();
  bool b = foo (bar ());
  if (!b)
    __builtin_abort ();
}

shows, the bug is cxx_eval_call_expression, when we are doing non-manifestly
constant-evaluated constexpr evaluation, we set
          /* Make sure we fold std::is_constant_evaluated to true in an
             immediate function.  */
          if (DECL_IMMEDIATE_FUNCTION_P (fun))
            call_ctx.manifestly_const_eval = mce_true;
but evaluate arguments of the immediate function before that.
In the a case, there is no constant evaluation done before cp_fold_function and
so the evaluation is correct in that case.

Reply via email to