]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/69158 (ICE in in cxx_eval_indirect_ref, at cp/constexpr.c:2598)
authorJason Merrill <jason@redhat.com>
Sat, 9 Jan 2016 05:12:03 +0000 (00:12 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 9 Jan 2016 05:12:03 +0000 (00:12 -0500)
PR c++/69158

* constexpr.c (cxx_fold_indirect_ref): Handle array type differing
in completion.

From-SVN: r232186

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/init/array40.C [new file with mode: 0644]

index 49dc0cfc5c3d14191a355bafc9614f24a9ebf9a1..8723cad590c8353a32f076fa67aefa635beb610e 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-08  Jason Merrill  <jason@redhat.com>
+
+       PR c++/69158
+       * constexpr.c (cxx_fold_indirect_ref): Handle array type differing
+       in completion.
+
 2016-01-08  Marek Polacek  <polacek@redhat.com>
 
        PR c++/68449
index 7b6027138f26ecbe456fe8d8747d94a3eab9e700..e60180ee6cdc7ac083bc4d44539f5b4c7952ab69 100644 (file)
@@ -2382,7 +2382,15 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base)
       if (TREE_CODE (op) == CONST_DECL)
        return DECL_INITIAL (op);
       /* *&p => p;  make sure to handle *&"str"[cst] here.  */
-      if (same_type_ignoring_top_level_qualifiers_p (optype, type))
+      if (same_type_ignoring_top_level_qualifiers_p (optype, type)
+         /* Also handle the case where the desired type is an array of unknown
+            bounds because the variable has had its bounds deduced since the
+            ADDR_EXPR was created.  */
+         || (TREE_CODE (type) == ARRAY_TYPE
+             && TREE_CODE (optype) == ARRAY_TYPE
+             && TYPE_DOMAIN (type) == NULL_TREE
+             && same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (optype),
+                                                           TREE_TYPE (type))))
        {
          tree fop = fold_read_from_constant_string (op);
          if (fop)
diff --git a/gcc/testsuite/g++.dg/init/array40.C b/gcc/testsuite/g++.dg/init/array40.C
new file mode 100644 (file)
index 0000000..5c976e2
--- /dev/null
@@ -0,0 +1,2 @@
+// PR c++/69158
+char IdHdr[] = { (IdHdr)[0] };