https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115260

--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
The following varient of the reduced test case works, where
field_type is not allocatable:

program usegnufields
  implicit none
  type :: field_type
    real  :: data(3)
  end type field_type
  type :: fieldholder
    type(field_type) :: fieldset(2,4)
  end type fieldholder
  type(fieldholder) :: myfields

  myfields%fieldset(2,1)%data =[1.0,2.0,3.0]
  print '(*(Z8.8:1X))',myfields%fieldset(2,1)%data

  call setfields (myfields%fieldset(2,1:4))
  print *,'After calling setfields with fieldset(2,1:4)'
  print '(*(Z8.8:1X))',myfields%fieldset(2,1)%data

contains
  subroutine setfields (fieldset)
    type(field_type), intent(inout) :: fieldset(1:4) ! corruption with -O
  end subroutine setfields
end

Reply via email to