12-203 To: J3 Members From: Stan Whitlock Subject: J3 Fortran interp letter ballot #27 - due 11-Jan-2013 Date: 24-Nov-2012 Enclosed in the next letter ballot on Fortran interpretations. The rules by which we operate say: o J3 votes on the answer at a J3 meeting; a simple majority vote marks the answer as "passed by J3 meeting". o Between J3 meetings the chair of /interp sends a J3 letter ballot to J3 to approve interp answers that have been "passed by J3 meeting". The letter ballot runs for 30 days. Not voting on three of four consecutive J3 letter ballots is grounds to terminate J3 membership. An interp answer passes by a 2/3rds vote; a no vote must be accompanied by an explanation of the changes necessary to change the member's vote to yes. J3/interp reserves the right to recall an interp answer for more study even if the answer passes. 6 Fortran interpretations are currently "Passed by J3 meeting" after J3 meeting #199. This is the letter ballot phase to go from "Passed by J3 meeting" to "Passed by J3 letter ballot". The following Fortran interpretations are being balloted: Yes No Number Title --- --- F03/0053 The BIND attribute for C_PTR and C_FUNPTR --- --- F08/0075 Pointer function reference as variable in assignment --- --- F08/0083 Type parameter default expressions allow circular dependence --- --- F08/0084 Pointer arguments to PURE functions --- --- F08/0085 Problems with PARAMETERs --- --- F08/0086 Implied-shape and separate PARAMETER statement The text of these interpretations is attached. Each interpretation starts with a row of "-"s. Please mark the above -Y- in the Yes column for "yes", -C- in the Yes column for "yes with comment", or -N- in the No column for a "no" answer {be sure to include your reasons with "no"} and send only the above text {not this entire mail message} with any comments to j3@j3-fortran.org by 11:59:59PM, PDT, Friday, 11-Jan-2013, in order to be counted. Thanks /Stan ------------------------------------------------------------------------ NUMBER: F03/0053 TITLE: The BIND attribute for C_PTR and C_FUNPTR KEYWORDS: BIND attribute, C_PTR, C_FUNPTR, private components DEFECT TYPE: Erratum STATUS: Passed by J3 letter ballot QUESTION: 1. Do the derived types C_PTR and C_FUNPTR have the BIND attribute? This affects whether an object of one of these types is permitted directly in COMMON. C5101 in the Fortran 2008 standard states "If a common-block-object is of a derived type, it shall be a sequence type or a type with the BIND attribute and it shall have no default initialization." 2. Whether the derived types C_PTR and C_FUNPTR have the BIND attribute affects whether they are extensible. Subclause 4.5.7.1 of the Fortran 2008 standard states "A nonsequence derived type that does not have the BIND attribute is an extensible type." Are these types extensible? 3. Subclause 15.3.3 of the Fortran 2008 standard states that C_PTR and C_FUNPTR are derived types with private components. Are user-defined derived types with the BIND attribute permitted to have private components? ANSWER: 1. No, these types do not have the BIND attribute. 15.3.3 does not specify that they have the BIND attribute. 15.3.4 does not require them to have the BIND attribute in order to make them interoperable. 15.3.5 would require them to interoperate with a C struct if they had the BIND attribute; this is absurd, since C object pointers and C function pointers are clearly not structs. Note that whether these types have default initialization is not specified by the standard, so possession of BIND would not necessarily have allowed them in COMMON anyway. Edits are provided to correct incomplete, and thus misleading, statements about derived types and the BIND attribute. 2. No, these types were not intended to be extensible. It was an oversight that these types were not explicitly excluded from being extensible by subclause 4.5.7.1 paragraph 1 of the Fortran 2008 standard. An edit is provided to correct this. 3. Yes, a user-defined derived type with the BIND attribute is permitted to have private components. This situation is the same as for SEQUENCE types, which are similar (but not interoperable). As with SEQUENCE types, making a component PRIVATE does prevent access, in a conforming program, to the component by a programmer who is sufficiently determined; however, it continues to fulfill the software engineering role for which it was intended. Note further that there are many other situations where two different Fortran derived types will interoperate with the same C derived type; this is not a defect in either standard, but simply a consequence of the two languages having different approaches to type compatibility. EDITS to 10-007r1: [19:15-16] In 1.3.147.6, replace the definition of "extensible type" with "type that may be extended using the EXTENDS clause (4.5.7.1)". {Repair definition of extensible type.} [77:3] In 4.5.7.1p1, After "A derived type" insert ", other than the type C_PTR or C_FUNPTR from the intrinsic module ISO_C_BINDING," {Prohibit these types from subsequent extension.} [431:6] In 15.3.4p1, replace entire paragraph with "Interoperability between derived types in Fortran and struct types in C is provided by the BIND attribute on the Fortran type." {Reduce misleading opening blather - this is just here so we didn't start the subclause with a bunch of constraints. Alternatively we could move paragraph 2 (and note 15.12) to replacce paragraph 1.} [431:12+2] In 15.3.4, Note 15.11, After "is interoperable" insert "with a C struct type". {Correct another misleading sentence.} [431:13-18] In 15.3.4p2, Change all four occurrences of "Fortran derived type" to "derived type"; change the single occurrence of "Fortran type" to "derived type". {Remove unnecessary and confusing qualification of "derived type" with "Fortran".} SUBMITTED BY: John Reid HISTORY: 05-151 m171 F03/0053 submitted - Passed by J3 meeting 05-170 m172 Passed J3 letter ballot #11 N1622 m172 Failed WG5 ballot N1629 11-217r1 m195 Revised answer for Fortran 2008 - Passed by J3 meeting 11-241 m196 Passed as amended by J3 letter ballot #24 11-229 12-165r2 m198 Passed by J3 letter ballot #25 12-147 12-193 m199 Failed WG5 ballot #3 N1932/N1933/N1939 12-190 m199 Revised answer/edits - passed by J3 meeting ---------------------------------------------------------------------- NUMBER: F08/0075 TITLE: Pointer function reference as variable in assignment KEYWORDS: Pointer function, assignment, defined operator DEFECT TYPE: Erratum STATUS: Passed by J3 meeting QUESTION: (1) Consider the following module Funcs interface operator ( .op. ) module procedure Unary, Binary end interface contains function Unary ( Arg ) integer, intent(in) :: Arg integer, pointer :: Unary ... end function Unary function Binary ( Arg1, Arg2 ) integer, intent(in) :: Arg1, Arg2 integer, pointer :: Binary ... end function Binary end module Funcs program What use Funcs integer :: X, Y = 42 10 .op. x = y end program What Is the "10" in "10 .op. x = y" an operand, and therefore an argument of a reference to Binary, or is .op. a reference to Unary and "10" a statement label? (2) Consider the following module Funcs interface operator ( .op. ) module procedure Unary, Binary end interface contains function Unary ( Arg ) integer, intent(in) :: Arg character(len=...), pointer :: Unary ... end function Unary function Binary ( Arg1, Arg2 ) integer, intent(in) :: Arg1, Arg2 character(len=...), pointer :: Binary ... end function Binary end module Funcs program What use Funcs integer :: X = 42, Y read (10) .op. x, y end program What Is "10" an , or is "(10) .op. x" a ? Note that this program is valid Fortran 90, and "(10) .op. x" is a according to the Fortran 90 standard. ANSWER: It was an oversight that the programs in (1) and (2) conform to the syntax and constraints in two different ways. The problem stems from the over-ambitious extension of allowing pointer function references to denote variables; this was unambiguous for syntax, but is not for operator syntax. Also, operator syntax has other restrictions on it that are intended to prevent modification of an operand, and these are subverted if the result is treated as a variable. Edits are supplied to remove the treatment of pointer-valued operators as variables. EDITS: [117:13] In 6.2, R602, change "" to "". [117:15] In 6.2, C602, change " ... has" to " shall have". [158:18+] In 7.2.2.2, R737, add new production "<> ". {Restore description of to F2003 version.} [158:20+] In 7.2.2.2, After C724, add new constraint "C724a (R737) An shall be a reference to a function that has a data pointer result." {Restore F2003 constraint (more or less).} SUBMITTED BY: Van Snyder HISTORY: 12-149 m198 F08/0075 submitted 12-149r1 m198 Revised edit 12-149r2 m198 Clarified answer, passed J3 meeting 12-196 m199 Subsumed F08/0076 and Failed J3 letter ballot #26, 12-184 12-197 m199 Revised answer/edits - passed by J3 meeting ---------------------------------------------------------------------- NUMBER: F08/0083 TITLE: Type parameter default expressions allow circular dependence KEYWORDS: type parameter expressions, circular dependence DEFECT TYPE: Erratum STATUS: Passed by J3 meeting QUESTION: Consider type :: T ( I, J ) integer, kind :: I = J + 1 integer, kind :: J = I + 1 end type T type(t) :: X(1,2) print *, x%i, x%j end 1. Is the program standard conforming? 2. What does it print? ANSWER: 1. The program is not conformant because the standard does not establish an interpretation. An edit is supplied to make it clear that the program is not comformant. 2. The standard does not establish an interpretation. EDITS: Replace item (9) in the list in 7.1.12p1 [12-007:152:9]: (9) "a previously declared kind type parameter of the type being defined," SUBMITTED BY: Van Snyder HISTORY: 12-172 m199 F08/0083 submitted - passed by J3 meeting ---------------------------------------------------------------------- NUMBER: F08/0084 TITLE: Pointer arguments to PURE functions KEYWORDS: PURE function, POINTER, INTENT(IN) DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: Consider the following subprogram: Real Pure Function F( X ) Real,Pointer :: X Real :: F f = 1.0 x = 2.0 ! (A) Nullify(x) ! (B) End Function F This subprogram does not conform to Fortran 2003, because both statements (A) and (B) violate constraint C1272 which says "C1272 In a pure subprogram any designator with a base object that ... is a dummy argument of a pure function ... shall not be used ... [in] a variable definition context ...". However, the corresponding constraint in Fortran 2008, C1283, is missing the condition that applies the constraint to a dummy argument of a pure function, except when it has INTENT(IN). Thus the statements marked (A) and (B) do not violate C1283, and therefore this subprogram appears to conform to Fortran 2008. Was this subprogram intended to be standard-conforming? ANSWER: No, this subprogram was not intended to be standard-conforming. An edit is supplied to re-insert the omitted condition. EDIT to 10-007r1: [312:31] In 12.7, constraint C1283, after "association", insert ", is a dummy argument of a pure function". SUBMITTED BY: Tobias Burnus HISTORY: 12-174 m199 F08/0084 submitted 12-174r1 m199 Revised 12-174r2 m199 Passed by J3 meeting ---------------------------------------------------------------------- NUMBER: F08/0085 TITLE: Problems with PARAMETERs KEYWORDS: PARAMETER DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: (1) Consider the program fragment Subroutine s Parameter (n=1) Integer :: x,n !(A) Parameter (x=3) The type declaration statement marked "!(A)", declares the entities X and N to be of type INTEGER. Furthermore, as we by the immediately preceding and following PARAMETER statements, both X and N are named constants. Unfortunately, a constraint says C507 (R503) "An shall appear if the entity is a named constant (5.3.13)." (BTW, R503 is .) Therefore one concludes that the type declaration statement marked "!(A)" is not conforming as it violates C507 for both X and N. Is this statement intended to be conforming? (2) Firstly, consider Subroutine s2(n) Integer,Parameter :: x(n:n+1) = [ 1,2 ] Character(n),Parameter :: y = 'abc' ... The type declaration statements are not conforming because according to 5.2.2p1, X and Y are automatic data objects, and C506 says that shall not appear in that case. Now consider Subroutine s2b(n) Implicit Character(n) (a-z) Parameter (y = 'abc') Integer :: x(n:n+1) Parameter(x=[1,2]) This is not valid Fortran 2003, because 5.2 contains the requirement: "The combination of attributes that may be specified for a particular entity is subject to the same restrictions as for type declaration statements regardless of the method of specification. This also applies to PROCEDURE, EXTERNAL, and INTRINSIC statements." This requirement does not appear in F2008. However, there is no indication in the Introduction of this new feature. Is this extension to Fortran 2003 deliberate? ANSWER: (1) Yes, the type declaration statement was intended to be allowed. An edit is supplied to correct this mistake. (2) No, the omission of this requirement was inadvertent. An edit is supplied to correct this mistake. EDITS: [88:14] In 5.2.1, Replace constraint "C507 (503)" completely with "C507 (R501) If the PARAMETER keyword appears, shall appear in each ." {Fix Q1.} [88:14+] In 5.2.1, immediately after constraint C507, insert new constraint: "C507a A that specifies a type parameter or array bound of a named constant shall be a constant expression." {Fix Q2.} SUBMITTED BY: Malcolm Cohen HISTORY: 12-189 m199 F08/0085 submitted 12-189r1 m199 Passed by J3 meeting ---------------------------------------------------------------------- NUMBER: F08/0086 TITLE: Implied-shape and separate PARAMETER statement KEYWORDS: Implied-shape, PARAMETER DEFECT TYPE: Clarification or Erratum STATUS: J3 consideration in progress QUESTION: Q1. Consider Program test1 Character(*) a,b(*) Dimension c(*) Parameter (a='123', b=['1','2','3']) Character(*),Parameter :: c = [ '44','55','66' ] Print *,a,b,c End The definition of the assumed-length character named constant A conforms to Fortran 77 to Fortran 2008. However, the definition of the implied-shape named constant B appears not to conform to Fortran 2008, as the standard says in 5.4.11p2 "A named array constant defined by a PARAMETER statement shall have its shape specified in a prior specification statement." On the other hand, the named constant C does not have such a requirement, so its definition would appear to be conforming. This apparent requirement on the named constant B would thus appear to be inconsistent with those on the named constant C, as well as inconsistent with the way that assumed length works, and with the general principle of allowing attributes to be specified either in a single type declaration statement or with separate specification statements. Is the program intended to conform to the Fortran standard? Q2. Consider Subroutine test2(a) Real,Dimension(*) :: a,b,c Integer,Parameter :: b = 123 Parameter (c = 45.6) a(b) = c End Subroutine The in the type declaration statement is ambiguous; if it is an then the declaration of A as an assumed-size array is erroneous, but if it is an then the declarations of B and C as implied-shape arrays is erroneous. Is this program-unit intended to be standard-conforming? ANSWER: A1. No, the program is not intended to conform to the Fortran standard. A clarifying edit is supplied to make it clear that an implied-shape array specification is only permitted for a named constant whose value is given in the same statement. This makes it clear that the declarations of both B and C are non-conforming. A2. No, the program is not intended to conform to the Fortran standard. This is clarified by the same edit that clarifies the answer to question 1. EDIT to 10-007r1: [97:27+] In 5.3.8.6, insert new constraint "C535a An shall appear only in a type declaration statement in which the PARAMETER keyword appears." SUBMITTED BY: Bill Long HISTORY: 12-191 m199 F08/0086 submitted - revised by Malcolm Cohen - passed by J3 meeting ----------------------------------------------------------------------