4 ! The program used to dereference a NULL pointer when trying to access
5 ! a pointer 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
21 ! WRITE(*,*) 'Both f1 and ff work if the optional parameter is present:'
24 ! WRITE(*,*) ' rr(1)=', rr(1), ' rr(2)=', rr(2)
25 IF (ANY(rr
/= (/ 110, 132 /))) CALL ABORT
29 ! WRITE(*,*) ' rr(1)=', rr(1), ' rr(2)=', rr(2)
30 IF (ANY(rr
/= (/ 110, 132 /))) CALL ABORT
34 ! WRITE(*,*) 'But only f1 works if the optional parameter is absent:'
38 ! WRITE(*,*) ' rr(1)=', rr(1), ' rr(2)=', rr(2)
39 IF (ANY(rr
/= (/ 110, 132 /))) CALL ABORT
43 ! WRITE(*,*) ' rr(1)=', rr(1), ' rr(2)=', rr(2)
44 IF (ANY(rr
/= (/ 110, 132 /))) CALL ABORT
51 REAL(KIND
=8), INTENT(IN
) :: a(:)
52 REAL(KIND
=8), DIMENSION(SIZE(a
)) :: ff
53 INTEGER, INTENT(IN
), POINTER :: b
54 REAL(KIND
=8), DIMENSION(2, SIZE(a
)) :: ac
57 ff
=SUM(gg(ac
,b
), dim
=1)
62 REAL(KIND
=8), INTENT(IN
) :: a(:)
63 REAL(KIND
=8), DIMENSION(SIZE(a
)) :: f1
64 INTEGER, INTENT(IN
), POINTER :: b
65 REAL(KIND
=8), DIMENSION(2, SIZE(a
)) :: ac
68 f1
=gg(ac(1,:),b
)+gg(ac(2,:),b
) ! This is the same as in ff, but without using the elemental feature of gg
71 ELEMENTAL
REAL(KIND
=8) FUNCTION gg(a
,b
)
73 REAL(KIND
=8), INTENT(IN
) :: a
74 INTEGER, INTENT(IN
), OPTIONAL
:: b