| 1 |
! { dg-do run } |
| 2 |
! PR106731 ICE on automatic array of derived type |
| 3 |
module causes_ice |
| 4 |
implicit none |
| 5 |
|
| 6 |
type :: t |
| 7 |
real(8) :: x |
| 8 |
contains |
| 9 |
procedure, private :: write_formatted |
| 10 |
generic :: write(formatted) => write_formatted |
| 11 |
end type t |
| 12 |
|
| 13 |
contains |
| 14 |
|
| 15 |
subroutine write_formatted(this, unit, iotype, v_list, iostat, iomsg) |
| 16 |
class(t), intent(in) :: this |
| 17 |
integer, intent(in) :: unit |
| 18 |
character(*), intent(in) :: iotype |
| 19 |
integer, intent(in) :: v_list(:) |
| 20 |
integer, intent(out) :: iostat |
| 21 |
character(*), intent(inout) :: iomsg |
| 22 |
write(unit, '(a,3x,f10.5)', iostat=iostat, iomsg=iomsg) 'dummy', this%x |
| 23 |
end subroutine write_formatted |
| 24 |
|
| 25 |
end module causes_ice |
| 26 |
|
| 27 |
module use_t |
| 28 |
use causes_ice |
| 29 |
implicit none |
| 30 |
|
| 31 |
public :: automatic_alloc |
| 32 |
|
| 33 |
contains |
| 34 |
|
| 35 |
subroutine automatic_alloc(n) |
| 36 |
integer, intent(in) :: n |
| 37 |
|
| 38 |
! Automatic array: ICE! |
| 39 |
type(t) :: automatic(n) |
| 40 |
|
| 41 |
! Allocatable: works |
| 42 |
type(t), allocatable :: alloc(:) |
| 43 |
allocate(alloc(n)) |
| 44 |
|
| 45 |
automatic%x = 42.34675_8 |
| 46 |
|
| 47 |
! Do anything |
| 48 |
print *, 'n=',n,automatic%x |
| 49 |
print *, 'n=',n,automatic |
| 50 |
|
| 51 |
end subroutine automatic_alloc |
| 52 |
|
| 53 |
end module use_t |
| 54 |
|
| 55 |
program test |
| 56 |
use use_t |
| 57 |
call automatic_alloc(1) |
| 58 |
end program test |