https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101988
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> I also noticed, GCC accepts while clang rejects:
> template<class T> struct A { A(T); };
> auto p = new A<int>[]{A(1),A(1)};
>
> While changing it to [2], both GCC and clang accepts it.
Note ICC and MSVC accepts the above so I think it is a clang bug.
Oh and GCC rejects this:
template<class T> struct A { A(T); };
auto p = new A[]{1,2};
But thinks A[] is really A:
<source>:2:21: error: class template argument deduction failed:
2 | auto p = new A[]{1,2};
| ^
<source>:2:21: error: no matching function for call to 'A(int, int)'
<source>:1:30: note: candidate: 'template<class T> A(T)-> A<T>'
1 | template<class T> struct A { A(T); };
| ^
<source>:1:30: note: template argument deduction/substitution failed:
<source>:2:21: note: candidate expects 1 argument, 2 provided
2 | auto p = new A[]{1,2};
| ^
<source>:1:26: note: candidate: 'template<class T> A(A<T>)-> A<T>'
1 | template<class T> struct A { A(T); };
| ^
<source>:1:26: note: template argument deduction/substitution failed:
<source>:2:21: note: mismatched types 'A<T>' and 'int'
2 | auto p = new A[]{1,2};
| ^
So that might get the hint of the problem.