public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-101988-4-CvDh9s5ZSM@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-101988-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101988 --- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:0c0f453c4af4880c522c8472c33eef42bee9eda1 commit r12-6894-g0c0f453c4af4880c522c8472c33eef42bee9eda1 Author: Marek Polacek <polacek@redhat.com> 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] = 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<class T> struct A { A(T); }; auto p = 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 == 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.
next prev parent reply other threads:[~2022-01-27 13:23 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-19 21:41 [Bug c++/101988] New: " ed at catmur dot uk 2021-08-19 22:52 ` [Bug c++/101988] [12 Regression] " pinskia at gcc dot gnu.org 2021-08-19 22:56 ` pinskia at gcc dot gnu.org 2021-08-19 23:01 ` pinskia at gcc dot gnu.org 2021-08-19 23:11 ` pinskia at gcc dot gnu.org 2021-08-20 9:03 ` redi at gcc dot gnu.org 2021-08-20 13:57 ` mpolacek at gcc dot gnu.org 2022-01-20 10:49 ` rguenth at gcc dot gnu.org 2022-01-27 13:23 ` cvs-commit at gcc dot gnu.org [this message] 2022-01-27 13:25 ` mpolacek at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-101988-4-CvDh9s5ZSM@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).