[J3] "Why C1529?" "If data-ref is an array, the referenced type-bound procedure shall have the PASS attribute"
Vipul Parekh
parekhvs at gmail.com
Tue Dec 13 21:57:18 UTC 2022
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/0a7fe397/attachment.htm>
More information about the J3
mailing list