[J3] another PURE example
parekhvs at gmail.com
Tue Oct 6 23:02:39 EDT 2020
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.
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 ---
integer, target, save :: x = 0
type :: t
integer, pointer :: p => x
use m, only : x, t
pure subroutine sub(a, b)
integer, intent(out) :: a, b
type(t) :: y
a = x
y%p = 1
b = x
use n, only : sub
integer :: a, b
call sub(a, b)
print *, "a = ", a, "; expected is 0"
print *, "b = ", b, "; is it 1?"
--- 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the J3