From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 77C113857C59; Thu, 19 Aug 2021 23:01:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77C113857C59 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101988] [12 Regression] Accepts invalid new-expression of array of deduced class template Date: Thu, 19 Aug 2021 23:01:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2021 23:01:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101988 --- Comment #3 from Andrew Pinski --- (In reply to Andrew Pinski from comment #2) > I also noticed, GCC accepts while clang rejects: > template struct A { A(T); }; > auto p =3D new A[]{A(1),A(1)}; >=20 > 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 struct A { A(T); }; auto p =3D new A[]{1,2}; But thinks A[] is really A: :2:21: error: class template argument deduction failed: 2 | auto p =3D new A[]{1,2}; | ^ :2:21: error: no matching function for call to 'A(int, int)' :1:30: note: candidate: 'template A(T)-> A' 1 | template struct A { A(T); }; | ^ :1:30: note: template argument deduction/substitution failed: :2:21: note: candidate expects 1 argument, 2 provided 2 | auto p =3D new A[]{1,2}; | ^ :1:26: note: candidate: 'template A(A)-> A' 1 | template struct A { A(T); }; | ^ :1:26: note: template argument deduction/substitution failed: :2:21: note: mismatched types 'A' and 'int' 2 | auto p =3D new A[]{1,2}; | ^ So that might get the hint of the problem.=