This is the same as pr70565 but it fails in an entirely different manner in the C front-end.

The problem here is that the parser builds an ARRAY_NOTATION_REF with a type of ptrdiff for length and stride. Later in cilkplus_extract_an_triplets we convert convert length and stride to an integer_type_node. This causes create_array_refs() to use a stride of integer_type, while the start is still a ptrdiff (verify_gimple ICE, boom).

The attached patch converts `start' to an integer_type to match the length and stride. We could either do this, or do a fold_convert if !useless_type_conversion_p in create_array_refs. I didn't want to look into cilkplus too deeply as to why we have different types, because (a) I don't care (b) we're probably going to deprecate Cilk Plus, no?

OK?

commit 494d38235e7a250f3f3b4d4c1950be9208917cce
Author: Aldy Hernandez <al...@redhat.com>
Date:   Tue Jan 17 08:27:57 2017 -0500

            PR c/79116
            * array-notation-common.c (cilkplus_extract_an_triplets): Convert
            start type to integer_type.

diff --git a/gcc/c-family/array-notation-common.c 
b/gcc/c-family/array-notation-common.c
index 061c203..3b95332 100644
--- a/gcc/c-family/array-notation-common.c
+++ b/gcc/c-family/array-notation-common.c
@@ -628,7 +628,9 @@ cilkplus_extract_an_triplets (vec<tree, va_gc> *list, 
size_t size, size_t rank,
          tree ii_tree = array_exprs[ii][jj];
          (*node)[ii][jj].is_vector = true;
          (*node)[ii][jj].value = ARRAY_NOTATION_ARRAY (ii_tree);
-         (*node)[ii][jj].start = ARRAY_NOTATION_START (ii_tree);
+         (*node)[ii][jj].start
+           = fold_build1 (CONVERT_EXPR, integer_type_node,
+                          ARRAY_NOTATION_START (ii_tree));
          (*node)[ii][jj].length
            = fold_build1 (CONVERT_EXPR, integer_type_node,
                           ARRAY_NOTATION_LENGTH (ii_tree));
diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pr79116.c 
b/gcc/testsuite/gcc.dg/cilk-plus/pr79116.c
new file mode 100644
index 0000000..9206aaf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cilk-plus/pr79116.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+int array[1024];
+void foo()
+{
+  _Cilk_for (int i = 0; i < 512; ++i)
+    array[:] = __sec_implicit_index(0);
+}

Reply via email to