From b6f12c83862bbb0bb60f766359662561ae8a312d Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 16 Dec 2012 10:45:12 +0000 Subject: [PATCH] re PR ada/54614 (Vector * Matrix -> Vector gives wrong result) PR ada/54614 Backport from mainline 2012-10-01 Vincent Pucci * s-gearop.adb (Vector_Matrix_Product): Fix dimension check and index of Left in S evaluation. From-SVN: r194535 --- gcc/ada/ChangeLog | 10 ++++++++++ gcc/ada/s-gearop.adb | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ec6af72bd9cf..370eff8ac1b7 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2012-12-16 Eric Botcazou + + PR ada/54614 + Backport from mainline + + 2012-10-01 Vincent Pucci + + * s-gearop.adb (Vector_Matrix_Product): Fix dimension check and index + of Left in S evaluation. + 2012-05-26 Eric Botcazou * gcc-interface/decl.c (variant_desc): Rename 'record' to 'new_type'. diff --git a/gcc/ada/s-gearop.adb b/gcc/ada/s-gearop.adb index 8f0d9e84dd01..7fc79b93d8c1 100644 --- a/gcc/ada/s-gearop.adb +++ b/gcc/ada/s-gearop.adb @@ -502,7 +502,7 @@ package body System.Generic_Array_Operations is R : Result_Vector (Right'Range (2)); begin - if Left'Length /= Right'Length (2) then + if Left'Length /= Right'Length (1) then raise Constraint_Error with "incompatible dimensions in vector-matrix multiplication"; end if; @@ -513,7 +513,7 @@ package body System.Generic_Array_Operations is begin for K in Right'Range (1) loop - S := S + Left (J - Right'First (1) + Left'First) * Right (K, J); + S := S + Left (K - Right'First (1) + Left'First) * Right (K, J); end loop; R (J) := S; -- 2.47.2