4 ! The program used to dereference a NULL pointer when trying to access
5 ! an allocatable dummy argument to be passed to an elemental subprocedure.
7 ! Original testcase from Andriy Kostyuk <kostyuk@fias.uni-frankfurt.de>
11 REAL(KIND
=8), DIMENSION(2) :: aa
, rr
12 INTEGER, ALLOCATABLE
:: b
20 ! WRITE(*,*) 'Both f1 and ff work if the optional parameter is present:'
23 ! WRITE(*,*) ' rr(1)=', rr(1), ' rr(2)=', rr(2)
24 IF (ANY(rr
/= (/ 110, 132 /))) CALL ABORT
28 ! WRITE(*,*) ' rr(1)=', rr(1), ' rr(2)=', rr(2)
29 IF (ANY(rr
/= (/ 110, 132 /))) CALL ABORT
33 ! WRITE(*,*) 'But only f1 works if the optional parameter is absent:'
37 ! WRITE(*,*) ' rr(1)=', rr(1), ' rr(2)=', rr(2)
38 IF (ANY(rr
/= (/ 110, 132 /))) CALL ABORT
42 ! WRITE(*,*) ' rr(1)=', rr(1), ' rr(2)=', rr(2)
43 IF (ANY(rr
/= (/ 110, 132 /))) CALL ABORT
50 REAL(KIND
=8), INTENT(IN
) :: a(:)
51 REAL(KIND
=8), DIMENSION(SIZE(a
)) :: ff
52 INTEGER, INTENT(IN
), ALLOCATABLE
:: b
53 REAL(KIND
=8), DIMENSION(2, SIZE(a
)) :: ac
56 ff
=SUM(gg(ac
,b
), dim
=1)
61 REAL(KIND
=8), INTENT(IN
) :: a(:)
62 REAL(KIND
=8), DIMENSION(SIZE(a
)) :: f1
63 INTEGER, INTENT(IN
), ALLOCATABLE
:: b
64 REAL(KIND
=8), DIMENSION(2, SIZE(a
)) :: ac
67 f1
=gg(ac(1,:),b
)+gg(ac(2,:),b
) ! This is the same as in ff, but without using the elemental feature of gg
70 ELEMENTAL
REAL(KIND
=8) FUNCTION gg(a
,b
)
72 REAL(KIND
=8), INTENT(IN
) :: a
73 INTEGER, INTENT(IN
), OPTIONAL
:: b