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

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The "deducing from brace-enclosed initializer" error is emitted during parsing
from listify.  The body of init_list is not potentially-constant (due to
erroneous FOR_COND), so we register_constexpr_fundef it with result ==
error_mark_node.

require_rvalue_constant_expression in finish_static_assert thinks init_list is
potentially-constant, so we call cxx_constant_value.  new_call.fundef->result
is error_mark_node so we don't bother evaluating the body.  We call
explain_invalid_constexpr_fn but that has nothing to say, so we end up with a
missing reason.
But we already said what went wrong, so we shouldn't repeat it here anyway.

The body is:

{
  int total = 0;

  <<cleanup_point   int total = 0;>>;
  {
    int x = <<< error >>>;
    <<< error >>> __for_range;
    <<< error >>> __for_begin;
    <<< error >>> __for_end;

    <<< Unknown tree: for_stmt

      <<< error >>>
      <<< error >>>
      <<cleanup_point       int x = <<< error >>>;>>;
      <<cleanup_point <<< Unknown tree: expr_stmt
        (void) (total = total + VIEW_CONVERT_EXPR<int>(x)) >>>>>;
       >>>;
  }
  return <retval> = VIEW_CONVERT_EXPR<int>(total) == 6;
}

Can be reproduced in C++20 with -Wno-invalid-constexpr.

Reply via email to