This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/29572] Bounds check should check size of array: d(1:1,1:1) = a(1:4,1:4)
- From: "tkoenig at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Jul 2008 08:15:57 -0000
- Subject: [Bug fortran/29572] Bounds check should check size of array: d(1:1,1:1) = a(1:4,1:4)
- References: <bug-29572-1719@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from tkoenig at gcc dot gnu dot org 2008-07-25 08:15 -------
This works now, with the fixes for matmul bounds checks
(PR 36341):
$ cat mat.f90
program mat
implicit none
complex, allocatable :: a(:,:),b(:,:)
complex :: d(1,1)
allocate(a(4,1),b(4,1))
a = cmplx(0.5,2.0)
b = cmplx(2.0,0.5)
d = matmul(a,transpose(b))
deallocate(a,b)
end program mat
$ gfortran -fbounds-check mat.f90
$ ./a.out
Fortran runtime error: Incorrect extent in return array in MATMUL intrinsic for
dimension 1: is 1, should be 4
$ cat mat-2.f90
program mat
implicit none
complex, allocatable :: a(:,:),b(:,:)
complex :: d(1,1)
allocate(a(4,1),b(4,1))
a = cmplx(0.5,2.0)
b = cmplx(2.0,0.5)
d = matmul(a,b)
deallocate(a,b)
end program mat
$ gfortran -fbounds-check mat-2.f90
$ ./a.out
Fortran runtime error: Incorrect extent in return array in MATMUL intrinsic for
dimension 1: is 1, should be 4
The case of user-defined functions also works:
$ cat f.f90
module a
contains
function f(x)
real, intent(in) :: x
real, dimension(3,3) :: f
f = x
end function f
end module a
program main
use a
real, dimension(2,2) :: b
b = f(1.0)
end program main
$ gfortran f.f90
f.f90:13.3:
b = f(1.0)
1
Error: Different shape for array assignment at (1) on dimension 1 (2 and 3)
Closing.
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29572