]> gcc.gnu.org Git - gcc.git/commit
c++: Fix ICE with structured binding initialized to incomplete array [PR97878]
authorJakub Jelinek <jakub@redhat.com>
Fri, 5 Feb 2021 09:22:07 +0000 (10:22 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 19 Mar 2021 23:27:47 +0000 (00:27 +0100)
commit8b7f2d3eae16dd629ae7ae40bb76f4bb0099f441
tree2d0673d66fd85cea56b49d0ce7c97a5cc3602983
parent025a0ee3911c0866c69f841df24a558c7c8df0eb
c++: Fix ICE with structured binding initialized to incomplete array [PR97878]

We ICE on the following testcase, for incomplete array a on auto [b] { a }; without
giving any kind of diagnostics, with auto [c] = a; during error-recovery.
The problem is that we get too far through check_initializer and e.g.
store_init_value -> constexpr stuff can't deal with incomplete array types.

As the type of the structured binding artificial variable is always deduced,
I think it is easiest to diagnose this early, even if they have array types
we'll need their deduced type to be complete rather than just its element
type.

2021-02-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/97878
* decl.c (check_array_initializer): For structured bindings, require
the array type to be complete.

* g++.dg/cpp1z/decomp54.C: New test.

(cherry picked from commit b229baa75ce4627d1bd38f2d3dcd91af1a7071db)
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp1z/decomp54.C [new file with mode: 0644]
This page took 0.060178 seconds and 5 git commands to generate.