On 6/18/19 11:54 AM, Marek Polacek wrote:
Here we ICE on

   template<typename T, T = T{}> // #1
   struct A {};

   template<typename T> void foo(A<T>) {}

   void bar() { foo(A<char>()); }

when deducing T in the non-type template parameter, because unify didn't
expect a CONSTRUCTOR:

     default:
       /* An unresolved overload is a nondeduced context.  */
       if (is_overloaded_fn (parm) || type_unknown_p (parm))
        return unify_success (explain_p);
       gcc_assert (EXPR_P (parm) || TREE_CODE (parm) == TRAIT_EXPR);

This works if T{} is replaced with T() in #1 -- then unify gets a CAST_EXPR,
which is EXPR_P.

Since here we're in a non-deduced context, I think we should simply accept
the CONSTRUCTOR and return unify_success.

I've also updated a comment that has gotten obsolete now.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2019-06-18  Marek Polacek  <pola...@redhat.com>

        PR c++/60223 - ICE with T{} in non-deduced context.
        * pt.c (unify): Allow COMPOUND_LITERAL_P in a non-deduced context.
        Update a comment.

OK.  We don't usually mention comments in the ChangeLog.

Jason

Reply via email to