To: J3 J3/23-119r1 From: Jon Steidel Subject: Interp F23-003 clarifying COMMON block names Date: 2023-February-24 ---------------------------------------------------------------------- NUMBER: F23/003 TITLE: Conflicting rules for COMMON block names KEYWORDS: COMMON Block, Named Constant, USE association renaming DEFECT TYPE: Clarification/Erratum STATUS: J3 consideration in progress REFERENCES: N2209 QUESTION: A survey of five compilers finds that three disallow a named constant from having the same name as a COMMON block in a give scope, while two compilers permit named constants sharing the same name as a COMMON block accessible in the same scope. 19.3.1 Classes of local identifiers, paragraph 1 establishes identifiers of names constants to be class (1) identifiers. Paragraph 2 states: "Within a scope, a local identifier of an entity of class (1) or class(4) shall not be the same as a global identifier used in that scope unless the global identifier o ... o is a common block name o ..." However, 19.3.2 Local identifiers that are the same as common block names states: "A name that identifies a common block in a scoping unit shall not be used to identify a constant or an intrinsic procedure in that scoping unit. ..." which disallows a named constant from having the same name as an accessible common block. 14.2.2 The USE statement and use association contains Note 4 which states "The constraints in 8.10.1, 8.10.2, and 8.9 prohibit the local-name from appearing in a COMMON statement, and equivalence-object in an EQUIVALENCE statement, or a namelist-group-name in a NAMELIST state- ment, respectively. There is no prohibition against the local-name appearing as a common-block-name or a namelist-group-object." The last sentence of this note contradicts the restrictions in 19.3.2. Q. Is the intent to disallow a local identifier that identifies a named constant from being the same as an accessible common block? ANSWER: Yes, the local identifier of a named constant cannot be the same as that of an accessible common block. This issue goes back to FORTRAN 77 when the PARAMETER statement was introduced. When Fortran 90 introduced MODULEs and USE association, the restriction on common block names was overlooked when the note was written. Clarifying edits are provided. EDITS to N2209: [299] 14.2.2 The USE statement and use association, NOTE 4, sentence 2 delete "a common-block-name or" add at the end of the note "Restrictions on local-name being the same as a common-block-name are detailed in 19.3.2." [528:15] 19.3.1 Classes of local identifiers, p2, after "is a common block name (19.3.2)" insert "and the local identifier is not that of a named constant or intrinsic procedure," SUBMITTED BY: Jon Steidel HISTORY: 23-119 m229 Submitted 23-119r1 m229 Revised edit location/description ----------------------------------------------------------------------