This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR85955
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 4 Jun 2018 15:58:56 +0200 (CEST)
- Subject: [PATCH] Fix PR85955
I am testing the following patch to fix an ICE with sincos
folding with mismatched arguments.
Bootstrap / regtest running on x86_64-unknown-linux-gnu.
Richard.
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.
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 261145)
+++ gcc/builtins.c (working copy)
@@ -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: gcc/testsuite/gcc.dg/pr85955.c
===================================================================
--- gcc/testsuite/gcc.dg/pr85955.c (nonexistent)
+++ gcc/testsuite/gcc.dg/pr85955.c (working copy)
@@ -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;
+}