NVHPC 26.5: default(present) fails for an empty inferred array section

Hello,

This code reproduces an issue I stumbbled across, which I tested with NVHPC 26.5 at both -O0 and -O3:

program test
  implicit none
  real, allocatable :: a(:), b(:)
  allocate(a(1),b(1))
  a = 1.
  b = 0.
  !$acc data copyin(a) copy(b)
  call kernel(a,b,1)
  !$acc end data
  print *, b
contains
  subroutine kernel(a,b,n)
    real, intent(in) :: a(:)
    real, intent(out) :: b(:)
    integer, intent(in) :: n
    integer :: i,k
    !$acc parallel loop default(present)
    do i=1,size(b)
      b(i) = 0.
      !$acc loop seq
      do k=2,n
        b(i) = b(i) + a(k)
      end do
    end do
  end subroutine kernel
end program test
nvfortran -acc -O0 -Minfo=accel test.f90 -o test
./test

Expected: b = 0, since the inner loop has zero iterations. Both arrays are already present.

Instead, the compiler infers a(2:n) and execution reports:

FATAL ERROR: data in PRESENT clause was not found on device 1: name=a(2:n)

Adding present(a) to the parallel-loop directive fixes it:

!$acc parallel loop default(present) present(a)

Is this a bug in handling implicitly inferred empty sections?

Thanks in advance!

Hi p-costa,

I was able to reproduce the behavior you saw and I think I agree that it’s wrong behavior. I opened a report with engineering about this labeled TPR#38994. When I hear back, I’ll let you know.

Thanks for reporting this to us!

Cheers,

Seth.