Optional allocatable arrays

Thomas Robitaille thomas.robitaille@gmail.com
Tue Oct 27 15:12:00 GMT 2009


Hello,

The following code causes a bus error when run, if compiled with  
either gfortran 4.2 or 4.4 (haven't tried other versions). I have no  
problems with g95 or ifort, so am wondering if this is a gfortran bug?

module test_module

   implicit none
   save

contains

   subroutine sub2(a)
     implicit none
     real,allocatable,intent(out),optional :: a(:)
     print *,'in sub2'
   end subroutine sub2

   subroutine sub1(a)
     implicit none
     real,allocatable,intent(out),optional :: a(:)
     print *,'in sub1'
     call sub2(a)
   end subroutine sub1

end module test_module

program test
   use test_module
   implicit none
   call sub1()
end program

The error is:

tom$ ./a.out
  in sub1
Bus error

Should this be reported as a bug? Can other users reproduce this bug?

Thanks for any help,

Thomas




More information about the Fortran mailing list