This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/91545 - ICE in constexpr store evaluation


Now that DECL_MUTABLE_P checks that it got a FIELD_DECL node, One Does Not
Simply Check DECL_P.  For an ARRAY_REF, "elt" can be a VAR_DECL.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2019-08-26  Marek Polacek  <polacek@redhat.com>

	PR c++/91545 - ICE in constexpr store evaluation.
	* constexpr.c (cxx_eval_store_expression): Check FIELD_DECL instead
	of DECL_P.

	* g++.dg/cpp0x/pr91545.C: New test.

diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index dbd0dc3b445..6c547d6d179 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -3849,7 +3849,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
 	  {
 	    tree ob = TREE_OPERAND (probe, 0);
 	    tree elt = TREE_OPERAND (probe, 1);
-	    if (DECL_P (elt) && DECL_MUTABLE_P (elt))
+	    if (TREE_CODE (elt) == FIELD_DECL && DECL_MUTABLE_P (elt))
 	      mutable_p = true;
 	    if (evaluated
 		&& modifying_const_object_p (TREE_CODE (t), probe, mutable_p)
diff --git gcc/testsuite/g++.dg/cpp0x/pr91545.C gcc/testsuite/g++.dg/cpp0x/pr91545.C
new file mode 100644
index 00000000000..2aa1fa18bd5
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/pr91545.C
@@ -0,0 +1,5 @@
+// PR c++/91545
+// { dg-do compile { target c++11 } }
+
+long a[1];
+int d, e { d && (a[d] = 0) };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]