4 ! Wrong code with pointer-bounds remapping
6 ! Contributed by Tobias Burnus <burnus@net-b.de>
9 integer, target
:: tgt(10)
10 integer, target
, allocatable
:: tgt2(:)
11 integer, pointer :: ptr(:)
13 tgt
= [1,2,3,4,5,6,7,8,9,10]
14 tgt2
= [1,2,3,4,5,6,7,8,9,10]
17 ptr(-5:) => tgt(5:) ! Okay
19 if (size(ptr
) /= 6 .or
. lbound(ptr
,1) /= -5) STOP 1
20 if (any (ptr
/= [5,6,7,8,9,10])) STOP 2
23 ptr(-5:) => tgt2(5:) ! wrongly associates the whole array
25 print '(*(i4))', size(ptr
), lbound(ptr
)
28 if (size(ptr
) /= 6 .or
. lbound(ptr
,1) /= -5) STOP 3
29 if (any (ptr
/= [5,6,7,8,9,10])) STOP 4