This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix ICE in build_ctor_subob_ref during replace_placeholders (PR c++/92524, take 2)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 27 Nov 2019 00:42:53 +0100
- Subject: [C++ PATCH] Fix ICE in build_ctor_subob_ref during replace_placeholders (PR c++/92524, take 2)
- References: <20191122141911.GC2466@tucnak> <ea2ee3ec-e6bd-0cdd-f292-c71daec07bc3@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Nov 26, 2019 at 04:58:01PM -0500, Jason Merrill wrote:
> Hmm, we shouldn't have any PLACEHOLDER_EXPR under a RANGE_EXPR; if we did,
> any references to its address would end up all referring to the first
> element of the range, which would be wrong. How about skipping RANGE_EXPR
> in replace_placeholders_r?
So like this?
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2019-11-27 Jakub Jelinek <jakub@redhat.com>
PR c++/92524
* tree.c (replace_placeholders_r): Don't walk constructor elts with
RANGE_EXPR indexes.
* g++.dg/cpp0x/pr92524.C: New test.
--- gcc/cp/tree.c.jj 2019-11-26 23:09:55.904101392 +0100
+++ gcc/cp/tree.c 2019-11-26 23:13:14.308070759 +0100
@@ -3144,6 +3144,11 @@ replace_placeholders_r (tree* t, int* wa
tree type = TREE_TYPE (*valp);
tree subob = obj;
+ /* Elements with RANGE_EXPR index shouldn't have any
+ placeholders in them. */
+ if (ce->index && TREE_CODE (ce->index) == RANGE_EXPR)
+ continue;
+
if (TREE_CODE (*valp) == CONSTRUCTOR
&& AGGREGATE_TYPE_P (type))
{
--- gcc/testsuite/g++.dg/cpp0x/pr92524.C.jj 2019-11-26 23:09:46.810240310 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr92524.C 2019-11-26 23:09:46.810240310 +0100
@@ -0,0 +1,12 @@
+// PR c++/92524
+// { dg-do compile { target c++11 } }
+
+struct A { char a = '*'; };
+struct B { A b[64]; };
+
+void
+foo ()
+{
+ A a;
+ B{a};
+}
Jakub