]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: fix ICE with designated initializer [PR110114]
authorMarek Polacek <polacek@redhat.com>
Wed, 19 Jul 2023 12:47:29 +0000 (08:47 -0400)
committerMarek Polacek <polacek@redhat.com>
Thu, 20 Jul 2023 14:32:48 +0000 (10:32 -0400)
commit2cb0dc866e8f95151df5d759157708108e850dd9
treef433d597f619f63a4e71a9e21cfc305680d76faf
parentb6b72562d116bd0a589dce39437f9d2b3c34491f
c++: fix ICE with designated initializer [PR110114]

r13-1227 added an assert checking that the index in a CONSTRUCTOR
is a FIELD_DECL.  That's a reasonable assumption but in this case
we never called reshape_init due to the type being incomplete, and
so the index remained an identifier node: get_class_binding never
got around to looking up the FIELD_DECL.

We can avoid the crash by returning early in implicit_conversion_1; we'd
return NULL anyway due to:

  if (i < CONSTRUCTOR_NELTS (ctor))
    return NULL;

in build_aggr_conv.

PR c++/110114

gcc/cp/ChangeLog:

* call.cc (implicit_conversion_1): Return early if the type isn't
complete.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist100.C: Adjust expected diagnostic.
* g++.dg/cpp2a/desig28.C: New test.
* g++.dg/cpp2a/desig29.C: New test.
gcc/cp/call.cc
gcc/testsuite/g++.dg/cpp0x/initlist100.C
gcc/testsuite/g++.dg/cpp2a/desig28.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/desig29.C [new file with mode: 0644]