[J3] "Why C1529?" "If data-ref is an array, the referenced type-bound procedure shall have the PASS attribute"
Robert Corbett
rpcorbett at att.net
Tue Dec 13 22:24:17 UTC 2022
It is not clear to me what the semantics of a procedure reference would be if NOPASS were to be allowed. Suppose sub was declared NOPASS and suppose instead of calling sub with a scalar argument, it was called with an array argument. How many times would sub be called? In the case of a function reference, what would the shape of the result be?
Bob Corbett
> On Dec 13, 2022, at 1:58 PM, Vipul Parekh via J3 <j3 at mailman.j3-fortran.org> wrote:
>
>
> This question is asked by OP in the following thread at comp.lang.fortran:
> https://groups.google.com/g/comp.lang.fortran/c/m-LqF2v2K58
>
> Consider the following:
> module m
> type :: t
> contains
> procedure, nopass :: sub
> end type
> contains
> elemental subroutine sub( x )
> integer, intent(inout) :: x
> x = x + 1
> end subroutine
> end module
> use m, only : t
> type(t) :: x(2)
> integer :: n
> n = 1
> call x%sub( n )
> end
>
> As indicated by OP with: C1529 in section 15.5.1 Syntax of a procedure reference in 18-007r1, page 301, paragraph 12 with "If data-ref is an array, the referenced type-bound procedure shall have the PASS attribute," the above program is nonconforming.
>
> So with this background, can you please provide your comments as to OP's question, "I'm wondering why this constraint exists, and whether to enforce it with a hard error message. Only two compilers do so; at least three don't care. There's nothing ambiguous about the resolution of the type-bound procedure when the base object is not scalar, so it seems best to accept it in the interest of making codes easier to port. But maybe I'm missing something subtle that makes strict enforcement of constraint C1529 necessary to avoid some otherwise bad or unimplementable behavior."
>
> Thank you,
> Vipul Parekh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20221213/c57f402b/attachment.htm>
More information about the J3
mailing list