[J3] Finalization Question
Vipul Parekh
parekhvs at gmail.com
Fri May 27 04:08:20 UTC 2022
On Thu, May 26, 2022 at 2:46 PM Brad Richardson via J3 <
j3 at mailman.j3-fortran.org> wrote:
> ..
> We attempted to test this doing something like the following:
>
> ..
>
> So the question then is:
>
> Is there any possible function that could be used in a specification
> expression, that would return a type that has a final subroutine?
> ..
>
> What do you all think?
>
My simple-minded thought is why seek a function "that would return a type
that has a final subroutine?"
Can not a simple specification function suffice if the purpose is to test
the semantics stated by Section 7.5.6.3, paragraph 6?
Can not something like the following help test standard conformance of
compilers, if that is the goal?
module m
type :: t
integer :: n = 42
contains
final :: final_t
end type
contains
elemental subroutine final_t( this )
type(t), intent(inout) :: this
this%n = 42
error stop "from final_t"
end subroutine
elemental function tlen( x ) result(r)
integer, intent(in) :: x
integer :: r
type(t) :: a
r = a%n + x
end function
subroutine sub()
character(len=tlen(1)) :: s
end subroutine
end module
use m
call sub()
end
Of the 3 compilers I tried, only one gave my expected output:
from final_t
Vipul Parekh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220527/62f06336/attachment.htm>
More information about the J3
mailing list