[J3] another PURE example

Robert Corbett rpcorbett at att.net
Sun Oct 11 09:39:25 EDT 2020


 I uploaded my interp request for PURE procedures.It is paper 20-151.  I am sorry it took so long tocomplete.
The paper does not provide a fix for the problemit describes.  The paper describes the problem,not the solution.  It mentions the fix that I favoras of this date 2020-10-11, but it does not go intodetail.  I doubt the committee will accept myproposed fix without amendment.
As I say in the paper, I think the committee needsto rethink how pure procedures are to be used andhow they are to be specified.  Van raised goodpoints regarding additional constraints that mightbe needed.
I want to thank everyone who provided feedback onmy examples and on earlier versions of my paper.The paper is better (and longer) because of thefeedback.
Robert Corbett

    On Tuesday, October 6, 2020, 10:37:21 PM PDT, Robert Corbett via J3 <j3 at mailman.j3-fortran.org> wrote:  
 
 I intend to file the interp papersoon.
You have seen the original example.You even commented on it.  I wrotemy new example, in part, becauseof your comments.
Bob Corbett
On Oct 6, 2020, at 8:02 PM, Vipul Parekh via J3 <j3 at mailman.j3-fortran.org> wrote:




On Tue, Oct 6, 2020 at 3:10 PM Robert Corbett via J3 <j3 at mailman.j3-fortran.org> wrote:

My original program, which will beincluded in my interp request, doesnot use modules, uses only onetype definition, and does not usea structure constructor.  Somepeople proposed fixes to theproblem that work for that program(which means they make thatprogram nonconforming), butwhich do not solve the problemin more complicated cases.  Mynew program demonstrates amore complicated case that isnot handled by some of theproposed fixes.  Simplifying mynew program would make itpointless, as it would no longerexhibit the difficult case.

Hi Bob,
Can you share details on the  original problem, perhaps any link to the email chain if you have that handy?
Otherwise, can you please comment whether your original problem is. by any chance, similar to this reduced case?
--- begin example ---module m
   integer, target, save :: x = 0
   type :: t
      integer, pointer :: p => x
   end type
end module
module n
   use m, only : x, t
contains
   pure subroutine sub(a, b)
      integer, intent(out) :: a, b
      type(t) :: y
      a = x
      y%p = 1
      b = x
   end subroutine
end module
   use n, only : sub
   integer :: a, b
   call sub(a, b)
   print *, "a = ", a, "; expected is 0"
   print *, "b = ", b, "; is it 1?"
end
--- end example ---

One processor I tried issued an error "Bad target in pointer assignment in PURE procedure" for module 'n'.  However, I am unable to come up with any clause in C1594 (or any constraints in 15.7 Pure Procedures) that clearly explains why this processor issues this diagnostic even if it is trying to do the right thing.
But now, no errors or warnings with another processor; the program built with it gave the following output:
 a =  0 ; expected is 0
 b =  1 ; is it 1?

The processor that issued the "Bad target in pointer assignment in PURE procedure" error in this reduced case also gave the same error with your new program.
Regards,Vipul

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


More information about the J3 mailing list