Attempting to compile the following code gives the error message below:
--
recursive real function det(A) result(res)
! Parameters.
real, dimension(:,:), intent(in) :: A
! Local variables.
real :: d
integer:: n
n = size(A,1)
d = 0.0
if (n==2) then
res = A(1,1)*A(2,2)-A(1,2)*A(2,1)
return
else if (n==3) then
d = A(1,1)*(A(2,2)*A(3,3)-A(3,2)*A(2,3))
d = d-A(1,2)*(A(2,1)*A(3,3)-A(3,1)*A(2,3))
d = d+A(1,3)*(A(2,1)*A(3,2)-A(3,1)*A(2,2))
res = d
return
else if (n==4) then
res = A(1,1)*det(A((/2,3,4/),(/2,3,4/))) &
-A(1,2)*det(A((/2,3,4/),(/1,3,4/))) &
+A(1,3)*det(A((/2,3,4/),(/1,2,4/))) &
-A(1,4)*det(A((/2,3,4/),(/1,2,3/)))
return
else
write(*,*) 'det for matrices bigger than 4x4 not implemented'
stop
end if
end function det
program main
real, dimension(4,4) :: A
integer :: i,j
do i = 1,4
do j = 1,4
call random_number(A(i,j))
end do
end do
write(*,*) det(A)
end program main
--
[EMAIL PROTECTED] detbug]$ gfortran -o detbug detbug.f90
detbug.f90: In function 'det':
detbug.f90:21: internal compiler error: in gfc_conv_ss_descriptor, at
fortran/trans-array.c:1265
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
[EMAIL PROTECTED] detbug]$ gfortran --version
GNU Fortran 95 (GCC 4.0.2 20051125 (Red Hat 4.0.2-8))
Copyright (C) 2005 Free Software Foundation, Inc.
GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
--
Summary: [gfortran] internal compiler error: in
gfc_conv_ss_descriptor, at fortran/trans-array.c:1265
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jchodera at gmail dot com
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28809