Hello world, the attached patch fixes the regression by converting the arguments to dot_product to the proper types.
Regression-tested on x86_64-unknown-linux-gnu. OK for all affected branches (trunk, 4.9 and 4.8)? Thomas 2014-08-10 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/61999 * simplify.c (gfc_simplify_dot_product): Convert types of vectors before calculating the result. 2014-08-10 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/61999 * gfortran.dg/dot_product_3.f90: New test case.
Index: simplify.c =================================================================== --- simplify.c (Revision 213778) +++ simplify.c (Arbeitskopie) @@ -1882,6 +1882,9 @@ gfc_expr* gfc_simplify_dot_product (gfc_expr *vector_a, gfc_expr *vector_b) { + + gfc_expr temp; + if (!is_constant_array_expr (vector_a) || !is_constant_array_expr (vector_b)) return NULL; @@ -1888,8 +1891,14 @@ gcc_assert (vector_a->rank == 1); gcc_assert (vector_b->rank == 1); - gcc_assert (gfc_compare_types (&vector_a->ts, &vector_b->ts)); + temp.expr_type = EXPR_OP; + gfc_clear_ts (&temp.ts); + temp.value.op.op = INTRINSIC_NONE; + temp.value.op.op1 = vector_a; + temp.value.op.op2 = vector_b; + gfc_type_convert_binary (&temp, 1); + return compute_dot_product (vector_a, 1, 0, vector_b, 1, 0, true); }
! { dg-do compile } ! { dg-options "-fdump-tree-original" } ! PR 61999 - this used to ICE. ! Original test case by A. Kasahara program main use, intrinsic:: iso_fortran_env, only: output_unit implicit none write(output_unit, *) dot_product([1, 2], [2.0, 3.0]) stop end program main ! { dg-final { scan-tree-dump-times "8\\.0e\\+0" 1 "original" } } ! { dg-final { cleanup-tree-dump "original" } }