This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Structure constructor and allocate seg faults


Hi,

The code below is generating seg faults on the two lines indicated in comments. Is the code incorrect, or is this a bug in the compiler? I've tested with gfortran 4.6.0 and 4.7.0 binaries installed on Mac OS X snow leopard 10.6.7.

Thanks,
Scott

module simple_module

implicit none

  private
  public item_type

  type :: item_type
    character(len=40), allocatable :: key
    real(kind=kind(1.d0)), dimension(:), allocatable :: value
  end type item_type

end module simple_module

program test_simple

use simple_module

implicit none

  type(item_type), dimension(:), allocatable :: items
  type(item_type) :: item
  real(kind=kind(1.d0)), dimension(:), allocatable :: value
  integer :: stat
  character(len=128) :: errmsg

value = [1.d0]

  ! next line causes seg fault
  item = item_type('key', value)

  ! next two lines work if above line is commented
  item%key = 'key'
  item%value = value

  ! next line causes seg fault
  allocate(items(1), stat=stat, errmsg=errmsg)
  items(1) = item

end program


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]