]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/58346 (ICE with SIGFPE at -O1 and above on x86_64-linux-gnu (affecting trunk...
authorMarek Polacek <polacek@redhat.com>
Fri, 17 Jan 2014 14:51:56 +0000 (14:51 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 17 Jan 2014 14:51:56 +0000 (14:51 +0000)
PR c/58346
* gimple-fold.c (fold_array_ctor_reference): Don't fold if element
size is zero.
testsuite/
* gcc.dg/pr58346.c: New test.

From-SVN: r206715

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr58346.c [new file with mode: 0644]

index 870d23233fafa11fc4d76bac00745a3f7016c11c..21b597144f47999a51ae0e3b86f733ebc628bd76 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-17  Marek Polacek  <polacek@redhat.com>
+
+       PR c/58346
+       * gimple-fold.c (fold_array_ctor_reference): Don't fold if element
+       size is zero.
+
 2014-01-17  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/46590
index 5dc27e172d9227e924a10281789ef015616d83cd..bace6f892d2ef5eb32ad056dc2a775f707888e8c 100644 (file)
@@ -2940,7 +2940,8 @@ fold_array_ctor_reference (tree type, tree ctor,
      be larger than size of array element.  */
   if (!TYPE_SIZE_UNIT (type)
       || TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST
-      || elt_size.slt (tree_to_double_int (TYPE_SIZE_UNIT (type))))
+      || elt_size.slt (tree_to_double_int (TYPE_SIZE_UNIT (type)))
+      || elt_size.is_zero ())
     return NULL_TREE;
 
   /* Compute the array index we look for.  */
index d8b972b86622d898a1a03683fafe85dcae42874e..a78e915bf780f4401f8920b930812b564a9c8ff7 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-17  Marek Polacek  <polacek@redhat.com>
+
+       PR c/58346
+       * gcc.dg/pr58346.c: New test.
+
 2014-01-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR testsuite/58776
diff --git a/gcc/testsuite/gcc.dg/pr58346.c b/gcc/testsuite/gcc.dg/pr58346.c
new file mode 100644 (file)
index 0000000..b7940f6
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR tree-optimization/58346 */
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+struct U {};
+static struct U b[1] = { };
+extern void bar (struct U);
+
+void
+foo (void)
+{
+  bar (b[0]);
+}
+
+void
+baz (void)
+{
+  foo ();
+}