Bugreport for nvfortran: Treatment of array bounds in the specification part

Hi all, recently I’ve faced an interesting difference in behaviour between nvfortran and e.g. gfortran.

Briefly, if there is a function, where in the specification part the ubounds/lbounds functions are used in the specification part, e.g.

 function justcopy(arr_in) 
   real, intent(in) :: arr_in(0:,:)
   real :: justcopy(0:ubound(arr_in,dim=1), 2:5) 

the actual size of the declared array will be different, as if ubound is calculated before the declaration of the array. See details An interesting difference between compilers - Help - Fortran Discourse
My assumption is that such a behaviour is a bug.

Best regards,

Thanks Andrii. I filed a report, TPR #34980, and sent it to engineering for investigation.