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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think the maybe_push_to_top_level is also the reason why the call to
std::meta::current_function() can't be evaluated (reflect_current_scope doesn't
give us the op() because ctx->call is empty) at first.  Then the lambda body
has "an immediate invocation that is not a constant expression" and we promote:

  if (DECL_IMMEDIATE_FUNCTION_P (decl))
    {    
      tree e = cxx_constant_value (stmt, tf_none);
      if (e == error_mark_node)
        {
          /* This takes care of, e.g.,
              template <typename T>
              constexpr int f(T t)
              {
                return id(t);
              }
            where id (consteval) causes f<int> to be promoted.  */
          if (immediate_escalating_function_p (current_function_decl))
            promote_function_to_consteval (current_function_decl);

Reply via email to