Run-time seg fault on automatic allocation of array
Rouson, Damian
rouson@sandia.gov
Mon Nov 8 04:45:00 GMT 2010
Given the code below, Gfortran 4.6.0 20100925 produces an executable that
generates a seg fault. Presumably this stems from the ongoing work on
automatic (re)allocation of arrays. Interestingly, IBM XL Fortran 13.1
produces the correct output (" array = 0 0"), while Intel Fortran 12.0 beta
produces the wrong result (" array =") without the seg fault.
Damian
$ cat assign_array.F90
module array_module
implicit none
integer ,dimension(:) ,allocatable :: array
contains
function zero()
integer ,dimension(:) ,allocatable :: zero
print *,'seg fault occurs after this line'
zero = [0,0]
print *,'seg fault occurs before this line'
end function
subroutine set_array
array = zero()
end subroutine
end module
program main
use array_module
implicit none
call set_array
print *,'array = ',array
end program
$ gfortran assign_array.F90
$ ./a.out
seg fault occurs after this line
Segmentation fault
$ gfortran --version
GNU Fortran (GCC) 4.6.0 20100925 (experimental)
Copyright (C) 2010 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
More information about the Fortran
mailing list