From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B56C7385ED40; Thu, 27 Jan 2022 13:23:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B56C7385ED40 From: "cvs-commit 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, 27 Jan 2022 13:23:19 +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: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: mpolacek 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, 27 Jan 2022 13:23:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101988 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:0c0f453c4af4880c522c8472c33eef42bee9eda1 commit r12-6894-g0c0f453c4af4880c522c8472c33eef42bee9eda1 Author: Marek Polacek Date: Wed Jan 26 17:29:19 2022 -0500 c++: new-expr of array of deduced class tmpl [PR101988] In r12-1933 I attempted to implement DR2397 aka allowing int a[3]; auto (&r)[3] =3D a; by removing the type_uses_auto check in create_array_type_for_decl. That may have gone too far, because it also allows arrays of CLASS_PLACEHOLDER_TEMPLATE and it looks like [dcl.type.class.deduct] prohibits that: "...the declared type of the variable shall be cv T, where T is the placeholder." However, in /2 it explicitly states that "A placeholder for a deduced class type can also be used in the type-specifier-seq in the new-type-id or type-id of a new-expression." In this PR, it manifested by making us accept invalid template struct A { A(T); }; auto p =3D new A[]{1}; [expr.new]/2 says that such a construct is treated as an invented declaration of the form A x[]{1}; but, I think, that ought to be ill-formed as per above. So this patch sort of restores the create_array_type_for_decl check. I should mention that the difference between [] and [1] is due to cp_parser_new_type_id: if (*nelts =3D=3D NULL_TREE) /* Leave [] in the declarator. */; and groktypename returning different types based on that. PR c++/101988 gcc/cp/ChangeLog: * decl.cc (create_array_type_for_decl): Reject forming an array= of placeholder for a deduced class type. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction-new1.C: New test. * g++.dg/cpp23/auto-array2.C: New test.=