public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7744] c++: initialized array of vla [PR58646] Date: Mon, 21 Mar 2022 22:25:40 +0000 (GMT) [thread overview] Message-ID: <20220321222540.D78DC385EC57@sourceware.org> (raw) https://gcc.gnu.org/g:c65bd532e225996cc9c5b75355d2cb648d0bcfc5 commit r12-7744-gc65bd532e225996cc9c5b75355d2cb648d0bcfc5 Author: Jason Merrill <jason@redhat.com> Date: Mon Mar 21 17:48:01 2022 -0400 c++: initialized array of vla [PR58646] We went into build_vec_init because we're dealing with a VLA, but then build_vec_init thought it was safe to just build an INIT_EXPR because the outer dimension is constant. Nope. PR c++/58646 gcc/cp/ChangeLog: * init.cc (build_vec_init): Check for vla element type. gcc/testsuite/ChangeLog: * g++.dg/ext/vla24.C: New test. Diff: --- gcc/cp/init.cc | 1 + gcc/testsuite/g++.dg/ext/vla24.C | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index 7575597c8fd..08767679dd4 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4395,6 +4395,7 @@ build_vec_init (tree base, tree maxindex, tree init, if (init && TREE_CODE (atype) == ARRAY_TYPE && TREE_CONSTANT (maxindex) + && !vla_type_p (type) && (from_array == 2 ? vec_copy_assign_is_trivial (inner_elt_type, init) : !TYPE_NEEDS_CONSTRUCTING (type)) diff --git a/gcc/testsuite/g++.dg/ext/vla24.C b/gcc/testsuite/g++.dg/ext/vla24.C new file mode 100644 index 00000000000..0a99c003ffb --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vla24.C @@ -0,0 +1,7 @@ +// PR c++/58646 +// { dg-additional-options -Wno-vla } + +void foo(int n) +{ + int a[2][n] = {}; +}
reply other threads:[~2022-03-21 22:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220321222540.D78DC385EC57@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@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).