Improve code generation of strided SLP loads
[official-gcc.git] / gcc / testsuite / gfortran.dg / elemental_assignment_1.f90
blob23d764313b26022a4ca657de25ea193c01016253
1 ! { dg-do run }
2 ! PR 67539 - this used to give a segfault at runtime.
3 ! Test case by "mrestelli".
5 module m
6 implicit none
8 type :: t_a
9 real, allocatable :: x
10 end type t_a
12 interface assignment(=)
13 module procedure copy_t_a
14 end interface
16 contains
18 elemental subroutine copy_t_a(y,x)
19 type(t_a), intent(in) :: x
20 type(t_a), intent(out) :: y
21 allocate( y%x , source=x%x )
22 end subroutine copy_t_a
24 elemental function new_t_a(x) result(res)
25 real, intent(in) :: x
26 type(t_a) :: res
27 allocate( res%x )
28 res%x = x
29 end function new_t_a
31 end module m
34 program p
35 use m
36 implicit none
38 integer :: i
39 type(t_a) :: tmp
40 type(t_a), allocatable :: v(:)
42 allocate( v(2) )
44 v = new_t_a(1.5) ! -> segmentation fault
46 !tmp = new_t_a(1.5) ! -> OK
47 !v = tmp
49 !do i=1,size(v) ! -> also OK
50 ! v(i) = new_t_a(1.5)
51 !enddo
53 do i=1,size(v)
54 write(*,*) " i = ",i
55 write(*,*) allocated(v(i)%x)
56 write(*,*) v(i)%x
57 enddo
59 end program p