]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ada/54614 (Vector * Matrix -> Vector gives wrong result)
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 16 Dec 2012 10:45:12 +0000 (10:45 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 16 Dec 2012 10:45:12 +0000 (10:45 +0000)
PR ada/54614
Backport from mainline

2012-10-01  Vincent Pucci  <pucci@adacore.com>

* s-gearop.adb (Vector_Matrix_Product): Fix dimension check and index
of Left in S evaluation.

From-SVN: r194535

gcc/ada/ChangeLog
gcc/ada/s-gearop.adb

index ec6af72bd9cf44ee209633b82b0738d693e93921..370eff8ac1b76360868155810048896c3a291e06 100644 (file)
@@ -1,3 +1,13 @@
+2012-12-16  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR ada/54614
+       Backport from mainline
+
+       2012-10-01  Vincent Pucci  <pucci@adacore.com>
+
+       * s-gearop.adb (Vector_Matrix_Product): Fix dimension check and index
+       of Left in S evaluation.
+
 2012-05-26  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (variant_desc): Rename 'record' to 'new_type'.
index 8f0d9e84dd012142bb66e6a659628812c318e88f..7fc79b93d8c166cc6b84d97d0e1b8a3266e66254 100644 (file)
@@ -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;