ISO/IEC JTC1/SC22/WG14 N578 Proposal UK006b - Restructuring of subclauses 6.1 and 6.2 ========================================================= Summary ------- Subclauses 6.1 and 6.2 are badly organised, and the former contains a number of ambiguities and inconsistencies. This proposal is a general cleanup. Conformance ----------- The author believes that no strictly-conforming program is affected by this proposal, and that the only changes are in the area of ambiguities where all existing implementations make the "right" choice. Discussion ---------- The following changes have been made. (1) The important concepts of scope, linkage, namespaces, storage durations, and types have been separated out from a subclause of a lexical concept to a major element of their own. To minimize impact, the text on conversions (6.2) is merged with this to become the new 6.1. The remainder of 6.1, which is actually the lexical elements, becomes 6.2. This aids the reader of the standard and reduces the need for forward references. It does not alter the language defined. (2) The current standard attempts to treat both operators and punctuators as syntactic elements. This means that several tokens (including the keyword "sizeof" occur twice. Instead, punctuator is made a syntactic concept, and operator a semantic one. The effect is to eliminate some minor syntactic ambiguities (various tokens have multiple derivations) and make the concepts clearer. It does not alter the language defined. (3) The header name changes of TC1 have been further amended for clarity. It does not alter the language defined. (4) Various nugatory constraints are eliminated. Any program which violates these constraints also violates one or more syntax rules. It does not alter the language defined. (5) The semantics of integer character constants are clarified. The sentence which refers to footnote 25 has been removed, and footnotes 24 and 25 combined and reworded. Detailed proposal ----------------- This proposal is best appreciated by reading the resulting text as a whole, rather than examining the detailed changes. The former is available for examination at the URL [not available publically]. This text is generated by the following changes, which form the proposal. Restructure subclauses 6.1 and 6.2 according to the following table, and alter cross-references throughout the Standard accordingly. New number Title Old number ------------------------------------------------------------ 6.1 Concepts none 6.1.1 Scopes of identifiers 6.1.2.1 6.1.2 Linkages of identifiers 6.1.2.2 6.1.3 Name spaces of identifiers 6.1.2.3 6.1.4 Storage durations of objects 6.1.2.4 6.1.5 Types 6.1.2.5 6.1.6 Compatible type and composite type 6.1.2.6 6.1.7 Conversions 6.2 6.1.7.1 Characters and integers 6.2.1.1 6.1.7.2 Signed and unsigned integers 6.2.1.2 6.1.7.3 Floating and integral 6.2.1.3 6.1.7.4 Floating types 6.2.1.4 6.1.7.5 Usual arithmetic conversions 6.2.1.5 6.1.7.6 Lvalues and function designators 6.2.2.1 6.1.7.7 void 6.2.2.2 6.1.7.8 Pointers 6.2.2.3 6.2 Lexical elements 6.1 6.2.1 Keywords 6.1.1 6.2.2 Identifiers 6.1.2 6.2.3 Constants 6.1.3 6.2.3.1 Floating constants 6.1.3.1 6.2.3.2 Integer constants 6.1.3.2 6.2.3.3 Enumeration constants 6.1.3.3 6.2.3.4 Character constants 6.1.3.4 6.2.4 String literals 6.1.4 6.2.5 Punctuators none 6.2.6 Header names 6.1.7 6.2.7 Preprocessing numbers 6.1.8 6.2.8 Comments 6.1.9 Delete the old subclauses 6.1.5 and 6.1.6; the new subclause 6.2.5 is given below. Insert and remove forward references according to the following table. [never completed] ====== In subclause 6.2 (formerly 6.1) syntax, remove the alternative "operator" from both "token" and "preprocessing-token". In the constraints, remove "an operator,". In the semantics, remove "operators," (twice), and combine the last two paragraphs into one, replacing: A header name at the start of the last paragraph, with There is one exception to this rule: a header name In subclause 6.2.2 (formerly 6.1.2), delete the constraints. In the semantics, replace: that will be described later: with described in subclause 6.1.1: Move the last paragraph of the implementation limits to the end of the semantics. In subclause 6.2.3.4 (formerly 6.1.3.4) description, delete the sentence: If any other escape sequence is encountered, the behaviour is undefined.25 Delete footnote 25. Add the following text at the end of footnote 24: If any other character follows a backslash, the result is not a token and a diagnostic is required. See ``future language directions'' (6.9.2). Replace the first paragraph of the semantics with: An integer character constant has type int. The value of an integer character constant containing a single character that maps into a member of the basic execution character set is the numerical value of the representation | of that character converted to type char and then to type int. | The value of an integer character constant containing a single | octal or hexadecimal escape sequence shall be the value of | that sequence converted to type char and then to type int. The value of an integer character constant containing more than one character, or containing a character or escape sequence not represented in the basic execution character set, is implementation-defined. (only the four marked lines are actually changed). Insert a new subclause 6.2.5 (replacing the old 6.1.5 and 6.1.6): Syntax punctuator: one of [ ] ( ) { } . -> ++ -- & * + - ~ ! / % << >> < > <= >= == != ^ | && || ? : ; ... = *= /= %= += -= <<= >>= &= ^= |= , # ## <: :> <% %> %: %:%: Semantics A punctuator is a symbol that has independent syntactic and semantic significance. Depending on context, it may specify an operation to be performed (which in turn may yield a value or a designator, or produce a side effect, or some combination) in which case it is known as an *operator* (other forms of operator also exist in some contexts). An *operand* is an entity on which an operator acts. In all aspects of the language, these six tokens <: :> <% %> %: %:%: behave, respectively, the same as these six tokens [ ] { } # ## except for their spelling.27 Forward references: expressions (6.3), declarations (6.5), preprocessing directives (6.8), statements (6.6). __________ 27. Thus [ and <: behave differently when ``stringized'' (see subclause 6.8.3.2), but can otherwise be freely interchanged. __________ In subclause 6.3.17, replace the first sentence of the example with: As indicated by the syntax, the comma operator (as described in this subclause) cannot appear in contexts where a comma is used to separate items in a list (such as arguments to functions or lists of initializers).