The following valid Fortran 95 program gives
  Fortran runtime error: Array bound mismatch
for GNU Fortran 95 (GCC) 4.1.0 (SUSE Linux) and
  Fortran runtime error: Array bound mismatch, upper bound of dimension 1 of
array 'rho' exceeded (in file 'main.f90', at line 12)
for GNU Fortran 95 (GCC) 4.2.0 20060608 (experimental).

-------<cut>--------------
program test
  implicit none
  real(8) :: rftp(4)
  rftp = 42.0_8
  call xcifc(n=4,rho=rftp)
contains
  subroutine xcifc(n,rho)
    implicit none
    integer, optional, intent(in) :: n
    real(8), optional, intent(in) :: rho(*)
    if(present(n).and.present(rho)) then
      print *,rho(1:n)
    end if
  end subroutine xcifc
end program test
--------------------------

Compiled as: gfortran -Wall -g -O0 -fbounds-check -Wconversion main.f90

If compiled without -fbounds-check, the output is ok.

Other compilers:
~> f95 -C=all -C=undefined -kind=byte main.f90 ; ./a.out
  42.0000000000000000  42.0000000000000000  42.0000000000000000 
42.0000000000000000
~> ifort -C -check all -warn all,nodec,interfaces -gen_interfaces -traceback
-fpe0 -fpstkchk -g -O0 main.f90; ./a.out
   42.0000000000000        42.0000000000000        42.0000000000000
   42.0000000000000


-- 
           Summary: gfortran gives "Array bound mismatch" for valid program
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobias dot burnus at physik dot fu-berlin dot de


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

Reply via email to