The following code (see the second test in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43829#c2 ) 

subroutine test1(esss,Ix,Iyz)
  real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss
  real(kind=kind(1.0d0)), dimension(:,:) :: Ix,Iyz
  esss = sum(Ix * Iyz, 0)
end subroutine

is invalid, but does not give any error when compiled with gfortran. I know
that "dim SHALL be between 1 and the rank of Ix*Iyz", so the constraint is on
the user. Nevertheless I think gfortran should detect the error. Note that the
executable for

module test
contains
subroutine test1(esss,Ix,Iyz)
  real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss
  real(kind=kind(1.0d0)), dimension(:,:) :: Ix,Iyz
  esss = sum(Ix * Iyz, 0)
end subroutine
end module test
use test
real(kind=kind(1.0d0)) :: a(5,5), b(5,5), s(5)
a = 2
b = 3
call test1(s, a, b)
print *, s
end

gives a "Segmentation fault".

I think the first test in the same comment

subroutine test1(esss,Ix,Iyz)
  real(kind=kind(1.0d0)), intent(out) :: esss
  real(kind=kind(1.0d0)), dimension(:) :: Ix,Iyz
  esss = sum(Ix * Iyz, 0)
end subroutine

is also invalid, but apparently the 0 is ignored and

module test
contains
subroutine test1(esss,Ix,Iyz)
  real(kind=kind(1.0d0)), intent(out) :: esss
  real(kind=kind(1.0d0)), dimension(:) :: Ix,Iyz
  esss = sum(Ix * Iyz, 0)
end subroutine
end module test
use test
real(kind=kind(1.0d0)) :: a(5), b(5), s
a = 2
b = 3
call test1(s, a, b)
print *, s
end

gives 30.0.


-- 
           Summary: Missed error for invalid SUM
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dominiq at lps dot ens dot fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44693

Reply via email to