Pointer to empty array

C.11.4 Pointers and targets as arguments
If a nonpointer dummy argument has the TARGET attribute and the corresponding actual argument does not, any pointers that become associated with the dummy argument, and therefore with the actual argument, during execution of the procedure, become undefined when execution of the procedure completes.

In your code, there is a possibility (e.g. if ARRAY%N = -10) that DATA remains undefined at function end. There is no “association status” of the function result when it is used for its value. If the function result is used in pointer context (e.g. VIEW(X) = TGT), and provided the IF statement did not fall through, then I think this will be conforming. However, any other POINTER that was associated, during VIEW, with the dummy ARRAY, will be undefined after VIEW terminates, if the actual argument was not a TARGET.

So any usage like this:

subroutine use_array(array)
    type(my_array), intent(inout) :: array ! no TARGET/POINTER
    print *, 'my array is: ',view(array)
end subroutine 

is not guaranteed to return a correct pointer to the data, even in the expression where the function is evaluated? (PS assume correct fallback for empty array)

I think the para from C.11.4 above does not apply to a pointer function result (provided a target has been associated with it during function execution) because the use is immediate (either as a value for an expression or as a target for a variable definition context).