J3/06-118 Date: January 20, 2006 To: J3 From: Aleksandar Donev Subject: LBOUND of array structure component NUMBER: F03/0077 TITLE: LBOUND of array structure component KEYWORDS: LBOUND, lower bounds, bounds, structure component, array sections DEFECT TYPE: CLARIFICATION/ERRATUM STATUS: J3 consideration in progress QUESTION: What is the result of this program: PROGRAM TYPE :: t REAL :: x END TYPE TYPE(t) :: y(-5:5) WRITE(*,*) LBOUND(y%x), LBOUND(y(3:5)%x) END PROGRAM ANSWER: Option 1) The program prints "1 1" Option 2) The program prints "-5 1" Note: There are compilers on both side of the spectrum, though it seems the majority print "1 1". I believe the intended answer is "1 1". Discussion: The definition of LBOUND: "If ARRAY is a whole array or array structure component and either ARRAY is an assumed-size array of rank DIM or dimension DIM of ARRAY has nonzero extent, LBOUND (ARRAY, DIM) has a value equal to the lower bound for subscript DIM of ARRAY. Otherwise the result value is 1." uses the phrase "array structure component", which can be read as "structure component that is an array" (which y%x and y(3:5)%x are), or "array component of a structure" (which neither y%x and y(3:5)%x are). The first reading says that the answer is equal to the lower bound of y%x, but the standard does not actually specify what the lower bounds of array sections are (since they cannot be subscripted). The second reading says that the answer is "1 1", and I believe it is the intended one. EDITS: Either: 1) Modify the words for LBOUND to say something alike "array component of a scalar of derived type" instead of "array structure component", or 2) Make an array component of a scalar of derived type be a "whole array" (this may have other consequences, but seems more intuitive than just tweaking the definition of LBOUND). Possibly also rewrite NOTE 6.6 to make it explicitly clear that something can be both a component and a section (assuming this is the intention), for example, add the sentence: "Some forms of are both a structure component and an array section." SUBMITTED BY: Aleksandar Donev HISTORY: J3/06-118 submitted at J3 meeting 175