[J3] Question on dummy CLASS(*) pointer arguments

Malcolm Cohen malcolm at nag-j.co.jp
Thu Nov 30 04:37:35 UTC 2023


This makes me wonder why this is CLASS(*),POINTER,INTENT(IN) at all?

 

CLASS(*),TARGET would work, and also permit passing non-pointer/target actual arguments. Maybe that is the reason, that you want to require the actual argument to be a target? Are you sure you really want to do that?

 

Making this valid would probably require a lot of extra words to make sure nothing gets broken. It is certainly not obvious that there is any functionality here worth the additional complication of the language.

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

 

From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Clune, Thomas L. (GSFC-6101) via J3
Sent: Thursday, November 30, 2023 2:45 AM
To: j3 <j3 at mailman.j3-fortran.org>
Cc: Clune, Thomas L. (GSFC-6101) <thomas.l.clune at nasa.gov>
Subject: [J3] Question on dummy CLASS(*) pointer arguments

 

Consider the code below:

 

program main

   implicit none

   real, pointer :: y(:)

 

   allocate(y(2))

   call s(y)

 

contains

 

   subroutine s(x)

      class(*), pointer, intent(in) :: x(:)

   end subroutine s

 

end program main

 

This is disallowed by the standard, presumably because the pointer array x could become associated with some other type.   However, since the dummy pointer has the INTENT(IN) attribute, I do not immediately see what could go wrong.   Is it simply that processors may want to have different representations for POINTER objects that we don’t want to force the conversion here?

 

Thanks,

 

*	Tom

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20231130/fb3c3078/attachment.htm>


More information about the J3 mailing list