https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80904
Bug ID: 80904
Summary: [6/7/8 Regression] Matmul result allocated to wrong
size
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: tkoenig at gcc dot gnu.org
Target Milestone: ---
Again: Add a new feature, find an old bug...
Test case:
! { dg-do run }
program main
real, dimension(3,2) :: a
real, dimension(3) :: bp
real, dimension(3) :: res1
real, dimension(:), allocatable :: c3
real, dimension(2) :: res2
data a /-2., 3., -5., 7., -11., 13./
data bp /-23., -31., -41./
data res2 /158., -353./
c3 = matmul(bp,a)
if (size(c3,1) /= 2) call abort
if (any(c3 /= res2)) call abort
end program main
One-character fix:
Index: frontend-passes.c
===================================================================
--- frontend-passes.c (Revision 248467)
+++ frontend-passes.c (Arbeitskopie)
@@ -2447,7 +2447,7 @@ matmul_lhs_realloc (gfc_expr *c, gfc_expr *a, gfc_
break;
case A1B2:
- ar->start[0] = get_array_inq_function (GFC_ISYM_SIZE, b, 1);
+ ar->start[0] = get_array_inq_function (GFC_ISYM_SIZE, b, 2);
cond = build_logical_expr (INTRINSIC_NE,
get_array_inq_function (GFC_ISYM_SIZE, c, 1),
get_array_inq_function (GFC_ISYM_SIZE, b, 2));