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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
struct S { constexpr S (int d, int e, int f) : a (d), b (e), c (f) {} int a, b;
private: int c; };

template <int N>
consteval void
foo ()
{
  constexpr S s = ((S) { 1, 2, 3 }); 
}
works fine, we also create CAST_EXPR in that case, but
fold_non_dependent_expr_template folds it away.
In the #c0 testcases it isn't folded away, because the CAST_EXPR doesn't exist
at that point yet, fold_non_dependent_expr_template sees CALL_EXPR to
members_of/enumerators_of etc.  Only when that it is constant evaluated (still
when processing_template_decl), CAST_EXPR is created and nothing folds it away.
So, I wonder if we don't need in reflect.cc in the 3 spots which use
finish_compound_literal also do afterwards
  if (processing_template_decl)
    {
      processing_template_decl_sentinel s;
      t = instantiate_non_dependent_expr_internal (t, complain);
    }
or something similar.  Or replace finish_compound_literal calls with something
else.

Reply via email to