[J3] another PURE example

Robert Corbett rpcorbett at att.net
Wed Oct 7 01:37:08 EDT 2020


I intend to file the interp paper
soon.

You have seen the original example.
You even commented on it.  I wrote
my new example, in part, because
of 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 be
>> included in my interp request, does
>> not use modules, uses only one
>> type definition, and does not use
>> a structure constructor.  Some
>> people proposed fixes to the
>> problem that work for that program
>> (which means they make that
>> program nonconforming), but
>> which do not solve the problem
>> in more complicated cases.  My
>> new program demonstrates a
>> more complicated case that is
>> not handled by some of the
>> proposed fixes.  Simplifying my
>> new program would make it
>> pointless, as it would no longer
>> exhibit 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/20201006/f4fbffc2/attachment.htm>


More information about the J3 mailing list