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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
To be precise, the CAST_EXPR doesn't have NULL TREE_TYPE initially, it has A
type, just NULL operand.
But then r245223 comes with:
                       if (processing_template_decl)
                         {
                           dependent_p = true;
                           scope = TREE_TYPE (postfix_expression) = NULL_TREE;
                         }
and clears the TREE_TYPE on the CAST_EXPR.

Slightly tweaked testcase that still ICEs:
struct A;

template<typename> void foo()
{
  static int a[A().operator=(A())];
}

which is accepted fine with extra struct A { operator int (); }; before the
template.
So, either we shouldn't clear the type and use something different to mark such
CAST_EXPRs as dependent, or potential_constant_expression_p and similar code
needs to handle CAST_EXPR with NULL TREE_TYPE.

Reply via email to