X3J3/96-057 Date: February 21, 1996 To: X3J3 From: Jeanne Martin Subject: User control of pointer bounds References: 120-JTM-8 (November 1991) WG5 Standing Document 5 (Repository), Item 2 X3J3/96-004 (JOR), Item 18 Given the following declarations: real, target :: b(0:9) real, pointer :: a(:), b_first(:), b_last(:) The situation with Fortran 95 is: a => b ! bounds are (0:9) a => b(:) ! bounds are (1:10) b_first => b(0:4) ! bounds are (1:5) b_last => b(5:9) ! bounds are (1:5) There is no way for the user to alter this determination of bounds. PROPOSAL A One proposal would be to add an optional lower bound specifier to the left side of the pointer assignment statement. Then a user would be able to write: a(0:) => b ! bounds are (0:9) a(0:) => b(:) ! bounds are (0:9) b_first(0:) => b(0:4) ! bounds are (0:4) b_last(5:) => b(5:9) ! bounds are (5:9) b_last(0:) => b(5:9) ! bounds are (0:4) PROPOSAL B An alternate proposal would, in addition, make a change to Fortran 95 such that unless a lower bound is specified, it is 1. This is a simple rule to remember. It would have the following effect: a => b ! bounds are (1:10) CHANGE a => b(:) ! bounds are (1:10) a(0:) => b ! bounds are (0:9) a(0:) => b(:) ! bounds are (0:9) ... Changing the standard at this time is a drastic step (even though this is a small change), and would require an explanation in section 1.5. Why should it even be considered? It is true the rule would be simpler, but also the language would be more consistent. Argument association is comparable to pointer assignment: real b(0:9) call sub(b) ... subroutine sub(x) ! This has the same effect as x => b(:) real x(:) ! The bounds of x are 1:10 ... end The rule for argument association is that x has the bounds (1:extent) unless a lower bound is specified in the declaration for x, for example real b(0:9) call sub(b) ... subroutine sub(x) ! This has the same effect as x(0:) => b real x(0:) ! The bounds of x are (0:9) ... end If the language were changed, there would be only one rule for both argument association and pointer assignment: Rule: The bounds are 1:extent unless a lower bound other than 1 is specified. Is this a good enough reason to change the standard? Straw vote: ___ Proposal A ___ Proposal B ___ neither ___ undecided