1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
! { dg-do run }
!
! Test the fix for PR92959, where compilation of ASSOCIATED segfaulted in 's1' and 's2'.
!
! Contributed by Gerhard Steinmetz <gscfq@t-online.de>
!
program p
character(:), pointer :: x, y => NULL()
character, pointer :: u, v => NULL ()
character(4), target :: tgt = "abcd"
! Manifestly not associated
x => tgt
u => tgt(1:1)
call s1 (.false., 1)
call s2 (.false., 2)
! Manifestly associated
y => x
v => u
call s1 (.true., 3)
call s2 (.true., 4)
! Zero sized storage sequences must give a false.
y => tgt(1:0)
x => y
call s1 (.false., 5)
contains
subroutine s1 (state, err_no)
logical :: state
integer :: err_no
if (associated(x, y) .neqv. state) stop err_no
end
subroutine s2 (state, err_no)
logical :: state
integer :: err_no
if (associated(u, v) .neqv. state) stop err_no
end
end
|