From: Eric Botcazou Date: Sun, 16 Dec 2012 10:45:12 +0000 (+0000) Subject: re PR ada/54614 (Vector * Matrix -> Vector gives wrong result) X-Git-Tag: releases/gcc-4.6.4~235 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6f12c83862bbb0bb60f766359662561ae8a312d;p=thirdparty%2Fgcc.git 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 --- 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;