1! { dg-do run } 2! 3! PR fortran/61138 4! Wrong code with pointer-bounds remapping 5! 6! Contributed by Tobias Burnus <burnus@net-b.de> 7 8implicit none 9integer, target :: tgt(10) 10integer, target, allocatable :: tgt2(:) 11integer, pointer :: ptr(:) 12 13tgt = [1,2,3,4,5,6,7,8,9,10] 14tgt2 = [1,2,3,4,5,6,7,8,9,10] 15 16 17ptr(-5:) => tgt(5:) ! Okay 18 19if (size(ptr) /= 6 .or. lbound(ptr,1) /= -5) STOP 1 20if (any (ptr /= [5,6,7,8,9,10])) STOP 2 21 22 23ptr(-5:) => tgt2(5:) ! wrongly associates the whole array 24 25print '(*(i4))', size(ptr), lbound(ptr) 26print '(*(i4))', ptr 27 28if (size(ptr) /= 6 .or. lbound(ptr,1) /= -5) STOP 3 29if (any (ptr /= [5,6,7,8,9,10])) STOP 4 30end 31 32