Bad array bounds with class(*) pointer rank remapping

The 18.4 compiler gives incorrect array bounds for pointer rank remapping assignments. This bug appears to be specific to class(*) pointers. Here’s an example:

class(*), allocatable, target :: array(:)
class(*), pointer :: p(:,:)
allocate(array, source=[1,2,3,4])
p(1:2,1:2) => array
print '(3(a,i0,1x,i0))', 'lbound=', lbound(p), ', ubound=', ubound(p), ', shape=', shape(p)
if (any(lbound(p) /= 1 .or. ubound(p) /= 2)) stop 1

The expected output is

lbound=1 1, ubound=2 2, shape=2 2

but pgfortran produces

lbound=1 0, ubound=4 0, shape=4 -65536

Hi NeilC,

I was able to reproduce this issue here and have created TPR#25704 and sent to engineering for further investigation.