re PR tree-optimization/71405 (ICE on valid C++ code at -Os and above on x86_64-linux...
authorJakub Jelinek <jakub@redhat.com>
Sat, 4 Jun 2016 14:50:57 +0000 (16:50 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 4 Jun 2016 14:50:57 +0000 (16:50 +0200)
PR tree-optimization/71405
* tree-ssa.c (execute_update_addresses_taken): For clobber with
incompatible type, build a new clobber with the right type instead
of building a VIEW_CONVERT_EXPR around it.

* g++.dg/torture/pr71405.C: New test.

From-SVN: r237091

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr71405.C [new file with mode: 0644]
gcc/tree-ssa.c

index 3e11cb9e06c349798f45dedfe27a5f14be67091d..e07d2deed22b4a004882810ebf4366339a19b00f 100644 (file)
@@ -1,3 +1,10 @@
+2016-06-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/71405
+       * tree-ssa.c (execute_update_addresses_taken): For clobber with
+       incompatible type, build a new clobber with the right type instead
+       of building a VIEW_CONVERT_EXPR around it.
+
 2016-06-04  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR tree-optimization/52171
index 94b4a33dd41ed5aa46ba058e55cdd985deb306c1..c272ade580901b8e6bfa0441280758340bd2dfaf 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/71405
+       * g++.dg/torture/pr71405.C: New test.
+
 2016-06-04  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/70202
diff --git a/gcc/testsuite/g++.dg/torture/pr71405.C b/gcc/testsuite/g++.dg/torture/pr71405.C
new file mode 100644 (file)
index 0000000..5260243
--- /dev/null
@@ -0,0 +1,22 @@
+// PR tree-optimization/71405
+// { dg-do compile }
+
+struct C
+{
+  C () {}
+  int i;
+};
+
+void *
+operator new (__SIZE_TYPE__ x, void *y)
+{
+  return y;
+}
+
+int
+main ()
+{
+  int a;
+  new (&a) C;
+  return a; 
+}
index a53322d9837ed1b683fb3350df11b85151973f44..2f3caf341ddce94076ce56f07ab9ccc7042c97ac 100644 (file)
@@ -1622,9 +1622,16 @@ execute_update_addresses_taken (void)
                if (gimple_assign_lhs (stmt) != lhs
                    && !useless_type_conversion_p (TREE_TYPE (lhs),
                                                   TREE_TYPE (rhs)))
-                 rhs = fold_build1 (VIEW_CONVERT_EXPR,
-                                    TREE_TYPE (lhs), rhs);
-
+                 {
+                   if (gimple_clobber_p (stmt))
+                     {
+                       rhs = build_constructor (TREE_TYPE (lhs), NULL);
+                       TREE_THIS_VOLATILE (rhs) = 1;
+                     }
+                   else
+                     rhs = fold_build1 (VIEW_CONVERT_EXPR,
+                                        TREE_TYPE (lhs), rhs);
+                 }
                if (gimple_assign_lhs (stmt) != lhs)
                  gimple_assign_set_lhs (stmt, lhs);