ISO/IEC JTC1/SC22/WG5 N1456 NUMBER: 000006 TITLE: Character length specification of a function result KEYWORDS: character, function result DEFECT TYPE: Interpretation STATUS: J3 consideration in progress QUESTION: Consider the following program: PROGRAM main CHARACTER(8) arg, func EXTERNAL func CALL sub(arg, func) END PROGRAM SUBROUTINE sub(arg, func) CHARACTER(*) arg, func CHARACTER(8) str str = func(arg) ... END SUBROUTINE CHARACTER(8) FUNCTION func(arg) CHARACTER(*) arg ... END FUNCTION Some implementations error the reference to FUNC in subroutine SUB and some do not. The implementations that do not error the reference to FUNC use essentially the following as the argument for allowing the reference: The rules for when an asterisk can be used to specify character length are specified on in section 5.1.1.5 (middle of page 51 of the Fortran 95 standard). * The first rule states that an asterisk may be used to declare a dummy argument of a procedure. It is clear that FUNC is a dummy argument of SUB. * The third rule says that in an external function, the length of the result may be specified within the function itself with an asterisk but if the result length is so specified, any invoker of the function must specify the character length of the function result as something other than an asterisk. But the function that is being invoked in the above example does not declare its result length using the asterisk, so this rule does not apply. Is the above sample program a standard conforming program with respect to the concept of declaring the function result length in the invoking program as an asterisk? ANSWER: Yes. When item (1) on page 51 is applied to the argument func of sub, it tells us that its length is 8 for the call from the main program. EDITS: None SUBMITTED BY: Larry Rolison HISTORY: J3/97-242 m143 submitted WG5/N1450 Draft answer -------------------------------------------------------------------------- NUMBER: 000026 TITLE: List-directed input: types of variables corresponding to repeated values KEYWORDS: DEFECT TYPE: STATUS: J3 consideration in progress QUESTION: Consider the example CHARACTER*80 STRING COMPLEX Z READ (*, *) Z, STRING Suppose the input consists of 2*(1.0, 0.0) After the READ, should Z contain (1.0,0.0) and should STRING contain '(1.0,'? ANSWER: No. This is not a standard-conforming statement. See the answer to interpretation number 000025. SUBMITTED BY: Robert Corbett HISTORY: 98-155 m145 Submitted (part 4) WG5/N1450 Draft answer ---------------------------------------------------------------------- NUMBER: F90/000212 TITLE: EQUIVALENCE of Data Objects of Different Types or Kinds KEYWORDS: EQUIVALENCE limitations DEFECT TYPE: STATUS: J3 consideration in progress Section 5.5.1 acknowledges that it is possible to construct equivalences between data objects of different types or kinds: "If equivalenced objects have differing type or type parameters, the EQUIVALENCE statement does not cause type conversion or imply mathematical equivalence." However, section 5.5.1 also has severe restrictions on equivalences between data objects of differing types and kinds. Following rule R547, there are a series of constraints. Constraints 3 through 6 read: Constraint: If an is of type default integer, default real, double precision real, default complex, default logical, or numeric sequence type, all of the objects in the equivalence set must be these types. Constraint: If an is of type default character or character sequence type, all of the objects in the equivalence set must be of these types. Constraint: If an is of a derived type that is not a numeric sequence or character sequence type, all of the objects in the equivalence set must be of the same type. Constraint: If an is of an intrinsic type other than default integer, default real, double precision real, default complex, default logical, or default character, all of the objects in the equivalence set must be of the same type with the same kind type parameter value. Question 1) Why are these constraints in the standard? What useful purpose do they serve? What problems do they prevent or solve? Question 2) Could a standard-conforming processor relax or eliminate one or more of these constraints, as an extension, without sacrificing full conformance to the standard? Question 3) Can a data object of sequence derived type be equivalenced to another data object of a different sequence derived type? Question 4) Assume that a processor has among its intrinsic types INTEGER (1) (8 bits), INTEGER (2) (16 bits), and INTEGER (4) (32 bits). Given the following definitions, is the EQUIVALENCE statement standard-conforming? TYPE T1 SEQUENCE INTEGER (1) I1_ARRAY (36) END TYPE TYPE T4 SEQUENCE INTEGER (4) I4_ARRAY (9) END TYPE TYPE (T1) OBJECT_1 TYPE (T4) OBJECT_4 EQUIVALENCE (OBJECT_1, OBJECT_4) Question 5) Can an object of sequence derived type be equivalenced to an array of intrinsic type? Question 5a) Assume the definitions of question 4. Is the following EQUIVALENCE statement standard conforming? INTEGER (4) :: I4_ARRAY_9 (9) EQUIVALENCE (OBJECT_1, I4_ARRAY_9) Question 6) Can an object of sequence derived type be equivalenced to a scalar of intrinsic type? ANSWER: Question 1: The constraints are there for portability (section 1.1) since different implementations may use different amounts of storage for these objects. Question 2: Such an extension is permitted, but the processor must provide the capability to detect this (see section 1.5). Question 3: Yes, a numeric sequence structure may be equivalenced to another numeric sequence structure and a character sequence structure may be equivalenced to another character sequence structure (see note 5.28). Question 4: No, this is not standard-conforming, because either INTEGER(1) or INTEGER(4) or both are non-default integers (see fourth constraint above). Question 5: Yes, a numeric sequence structure may be equivalenced to an array of default integer type, default real type, double precision real type, default complex type, or default logical type, and a character sequence structure may be equivalenced to an array of default character type (see note 5.28). Question 5a: No, this is not standard-conforming, because either INTEGER(1) or INTEGER(4) or both are non-default integers (see fourth constraint above). Question 6: Yes, a numeric sequence structure may be equivalenced to a scalar of default integer type, default real type, double precision real type, default complex type, or default logical type, and a character sequence structure may be equivalenced to a scalar of default character type (see note 5.28). EDIT: None SUBMITTED BY: Craig Dedo (Craig.Dedo@mixcom.com) HISTORY: submitted Jan. 23, 1996 (first appeared in 96-006r2) WG5/N1450 draft answer ====================================================================== Part 4: Interpretation Requests of Japan ====================================================================== NUMBER: JP-04 TITLE: Construction of derived-type values KEYWORDS: DEFECT TYPE: STATUS: J3 consideration in progress QUESTION: JP-4) 4.4.4 Construction of derived-type values Before NOTE 4.34: "Where a component in the derived type is a pointer, the corresponding constructor expression shall evaluate to an object that would be an allowable target for such a pointer in a pointer assignment statement (7.5.2)." Change `an object' to `a result value'. A value of an expression can not be an object, by definition. ANSWER: An edit is required but the proposed edit is not quite correct, because the expression might yield a null pointer. EDIT: Replace [45:7-9] by "Where a component in the derived type is a pointer, the corresponding constructor expression shall be an allowable for such a pointer in a pointer assignment statement (7.5.2)." SUBMITTED BY: Japan HISTORY: 99-208 Submitted 99-221 Classed as Fortran 95 Interpretation. WG5-N1411 Draft answer 00-260 m154 Passed by J3 meeting 00-329 m155 Failed J3 letter ballot WG5/N1450 Accepted Steidel's comment ---------------------------------------------------------------------- NUMBER: JP-08 TITLE: Type declaration statements KEYWORDS: DEFECT TYPE: STATUS: J3 consideration in progress QUESTION: JP-8) 5.1 Type declaration statements After NOTE 5.3 [49:8]: "If a length-selector (5.1.1.5) is a nonconstant expression, ..." Change `length-selector' to `char-selector', `char-len-selector' or `character-length'. ANSWER: Agreed, but we think that "char-len-param-value" would be a better replacement text. EDIT: [49:9] Replace "length-selector" by "char-len-param-value". SUBMITTED BY: Japan HISTORY: 99-208 Submitted 99-221 Classed as Fortran 95 Interpretation. WG5-N1411 Draft answer 00-260 m154 Passed by J3 meeting 00-329 m155 Failed J3 letter ballot WG5/N1450 Accepted Zongaro's comment ---------------------------------------------------------------------- NUMBER: JP-16 TITLE: Multiple occurrence of namelist-group-name in NAMELIST statement KEYWORDS: DEFECT TYPE: STATUS: J3 consideration in progress QUESTION: JP-16) 5.4 2nd paragraph after R545 and constraints (Page 66 Line 11) states that: "Any namelist-group-name may occur in more than one NAMELIST statement in a scoping unit." Can a namelist-group-name occur more than once in one NAMELIST statement ? Is the following NAMELIST statement standard conforming ? NAMELIST /NLIST/ A, B /NLIST/ C, D If this is standard conforming, is it the same as the following ? NAMELIST /NLIST/ A, B, C, D ANSWER: Yes, the rules should be analogous to those for named common blocks at [69:16-19]. EDIT: [66:11] Replace "in more than one" by "more than once in the" [66:11] Replace "statement" by "statements" SUBMITTED BY: Japan HISTORY: 99-208 Submitted 99-221 Classed as Fortran 95 Interpretation. WG5-N1411 Draft answer 00-260 m154 Passed by J3 meeting 00-329 m155 Failed J3 letter ballot WG5/N1450 Accepted Hirchert's comment ----------------------------------------------------------------------