[gcc(refs/vendors/redhat/heads/gcc-8-branch)] backport: re PR c++/92524 (ICE in short program with constexpr and std::array)

Jakub Jelinek jakub@gcc.gnu.org
Thu Sep 17 16:39:42 GMT 2020


https://gcc.gnu.org/g:b26685bc42c0833a306b7f3ceccfa128cc80a45c

commit b26685bc42c0833a306b7f3ceccfa128cc80a45c
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 14 12:51:28 2020 +0100

    backport: re PR c++/92524 (ICE in short program with constexpr and std::array)
    
            Backported from mainline
            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.

Diff:
---
 gcc/cp/ChangeLog                     |  6 ++++++
 gcc/cp/tree.c                        |  5 +++++
 gcc/testsuite/ChangeLog              |  8 ++++++++
 gcc/testsuite/g++.dg/cpp0x/pr92524.C | 12 ++++++++++++
 4 files changed, 31 insertions(+)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b7f28bb8191..43c164b4c36 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,6 +1,12 @@
 2020-02-14  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from mainline
+	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.
+
 	2019-11-26  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/92648
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 76b20ce659e..9cf3ad42533 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -3192,6 +3192,11 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_)
 	    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))
 	      {
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b3a8a4e3c44..f16e03e927f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2020-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from mainline
+	2019-11-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/92524
+	* g++.dg/cpp0x/pr92524.C: New test.
+
 2020-02-14  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from mainline
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr92524.C b/gcc/testsuite/g++.dg/cpp0x/pr92524.C
new file mode 100644
index 00000000000..ffbcd8f9f3a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr92524.C
@@ -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};
+}


More information about the Gcc-cvs mailing list