This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix PR 32336 (error message for matmul)

Hello world,

this patch is self-explanatory - using an error message on invalid user
code is better than raising an assert.

Regtesting on i686-pc-linux-gnu as I write this.

OK for trunk if this passes?


2007-07-09  Thomas Koenig  <>

	PR libfortran/32336
	* m4/matmul.m4:  When the dimension of b is incorrect,
	raise a runtime error instead of a failed assertion.
	* generated/matmul_i1.c:  Regenerated.
	* generated/matmul_i2.c:  Regenerated.
	* generated/matmul_i4.c:  Regenerated.
	* generated/matmul_i8.c:  Regenerated.
	* generated/matmul_i16.c:  Regenerated.
	* generated/matmul_r4.c:  Regenerated.
	* generated/matmul_r8.c:  Regenerated.
	* generated/matmul_r10.c:  Regenerated.
	* generated/matmul_r16.c:  Regenerated.

2007-07-09  Thomas Koenig  <>

	PR libfortran/32336
	* gfortran.dg/matmul_5.f90:  New test case.
Index: m4/matmul.m4
--- m4/matmul.m4	(revision 126460)
+++ m4/matmul.m4	(working copy)
@@ -171,7 +171,8 @@ sinclude(`matmul_asm_'rtype_code`.m4')dn
       xcount = a->dim[0].ubound + 1 - a->dim[0].lbound;
-  assert(count == b->dim[0].ubound + 1 - b->dim[0].lbound);
+  if (count != b->dim[0].ubound + 1 - b->dim[0].lbound)
+    runtime_error ("dimension of array B incorrect in MATMUL intrinsic");
   if (GFC_DESCRIPTOR_RANK (b) == 1)
! { dg-do run }
! { dg-shouldfail "dimension of array B incorrect in MATMUL intrinsic" }
program main
  real, dimension(:,:), allocatable :: a
  real, dimension(:), allocatable :: b
  allocate (a(2,2), b(3))
  call random_number(a)
  call random_number(b)
  print *,matmul(a,b)
end program main
! { dg-output "Fortran runtime error: dimension of array B incorrect in MATMUL intrinsic.*"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]