(j3.2006) lower bounds of results of array valued functions
Robert Corbett
Robert.Corbett
Fri Jul 24 23:16:55 EDT 2009
Consider the following program
FUNCTION F()
POINTER F
REAL F(:)
ALLOCATE(F(3:4))
END
FUNCTION G()
REAL G(4:5)
G = 0.0
END
FUNCTION H()
REAL, ALLOCATABLE :: H(:)
ALLOCATE(H(5:6))
H = 0.0
END
PROGRAM TEST
REAL A(2:3)
ALLOCATABLE B
REAL B(:)
INTERFACE
FUNCTION F()
POINTER F
REAL F(:)
END FUNCTION
END INTERFACE
INTERFACE
FUNCTION G()
REAL G(4:5)
END FUNCTION
END INTERFACE
INTERFACE
FUNCTION H()
REAL, ALLOCATABLE :: H(:)
END FUNCTION
END INTERFACE
PRINT *, LBOUND(A)
PRINT *, LBOUND((A))
PRINT *, LBOUND(F())
PRINT *, LBOUND(G())
PRINT *, LBOUND(H())
B = H()
PRINT *, LBOUND(B)
END
One vendor's implementation (not Sun's) produces the following output
for the program
2
1
3
4
5
5
Another implementation produces
2
1
1
1
1
1
Two other implementations produce
2
1
1
1
1
and an error.
I can see how to interpret the standard to allow either of the first two
sets of results. I suspect that most members of the committee would say
that the second set of results is correct. Does anyone think the first
set of results matches the intent of the standard?
I was surprised by the second line of the results. I thought that a
parenthesized whole array would still be a whole array.
I am interested in knowing if any other implementations produce results
that differ from the second set of results.
Robert Corbett
More information about the J3
mailing list