re PR middle-end/85955 (ICE in fold_convert_loc, at fold-const.c:2408)
authorRichard Biener <rguenther@suse.de>
Mon, 4 Jun 2018 18:03:24 +0000 (18:03 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 4 Jun 2018 18:03:24 +0000 (18:03 +0000)
2018-06-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/85955
* builtins.c (fold_builtin_sincos): Convert pointers to
destination to appropriate type before dereferencing.

* gcc.dg/pr85955.c: New testcase.

From-SVN: r261165

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr85955.c [new file with mode: 0644]

index 6f3e6543b8f9975fe5246679272939dc1d23e3ea..fda150a04265221ede28b230b800aafb8bb58ba5 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-04  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/85955
+       * builtins.c (fold_builtin_sincos): Convert pointers to
+       destination to appropriate type before dereferencing.
+
 2018-06-04  Segher Boessenkool  <segher@kernel.crashing.org>
 
        * config/rs6000/rs6000.md (abs<mode>2 for FLOAT128): Handle IFmode.
index c96ac38e8e9adc1ba1f496e5c89a79405882fdac..d4150d877dda02b1b4a6a71122bae4723cd22b53 100644 (file)
@@ -8266,6 +8266,9 @@ fold_builtin_sincos (location_t loc,
       call = builtin_save_expr (call);
     }
 
+  tree ptype = build_pointer_type (type);
+  arg1 = fold_convert (ptype, arg1);
+  arg2 = fold_convert (ptype, arg2);
   return build2 (COMPOUND_EXPR, void_type_node,
                 build2 (MODIFY_EXPR, void_type_node,
                         build_fold_indirect_ref_loc (loc, arg1),
index e27cf415b704965017522f3be9264cbe997dad9d..821e08865fa13e48e28bcfbc389b531fbbecd7a3 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-04  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/85955
+       * gcc.dg/pr85955.c: New testcase.
+
 2018-06-04  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/85981
diff --git a/gcc/testsuite/gcc.dg/pr85955.c b/gcc/testsuite/gcc.dg/pr85955.c
new file mode 100644 (file)
index 0000000..7f67f62
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+
+extern void sincos(double x, double *sinx, double *cosx);
+void apply(void (*f)(double, double *, double *),
+          double x, double *sinx, double *cosx)
+{
+  f(x, sinx, cosx);
+  return;
+}
+void apply_sincos(double x, double **sinx, double **cosx)
+{
+  apply(sincos, x, sinx, cosx);
+  return;
+}