*/ } ul /* Whole unordered list */ { } ul li /* Unordered list item */ { } ol /* Whole ordered list */ { } ol li /* Ordered list item */ { } hr {} /* ---- Some span elements --- */ sub /* Subscripts. Pandoc: H~2~O */ { } sup /* Superscripts. Pandoc: The 2^nd^ try. */ { } em /* Emphasis. Markdown: *emphasis* or _emphasis_ */ { } em > em /* Emphasis within emphasis: *This is all *emphasized* except that* */ { font-style: normal; } blockquote > p > em /* Emphasis within emphasis: *This is all *emphasized* except that* */ { font-style: normal; } blockquote > * > p > em /* Emphasis within emphasis: *This is all *emphasized* except that* */ { font-style: normal; } blockquote > p > ins > em /* Emphasis within emphasis: *This is all *emphasized* except that* */ { font-style: normal; } blockquote > * > p > ins > em /* Emphasis within emphasis: *This is all *emphasized* except that* */ { font-style: normal; } /* ---- Links (anchors) ---- */ a /* All links */ { /* Keep links clean. On screen, they are colored; in print, they do nothing anyway. */ text-decoration: none; } @media screen { a:hover { /* On hover, we indicate a bit more that it is a link. */ text-decoration: underline; } } @media print { a { /* In print, a colored link is useless, so un-style it. */ color: black; background: transparent; } a[href^="http://"]:after, a[href^="https://"]:after { /* However, links that go somewhere else, might be useful to the reader, so for http and https links, print the URL after what was the link text in parens */ content: " (" attr(href) ") "; font-size: 90%; } } /* ---- Images ---- */ img { /* Let it be inline left/right where it wants to be, but verticality make it in the middle to look nicer, but opinions differ, and if in a multi-line paragraph, it might not be so great. */ vertical-align: middle; } div.figure /* Pandoc figure-style image */ { /* Center the image and caption */ margin-left: auto; margin-right: auto; text-align: center; font-style: italic; } p.caption /* Pandoc figure-style caption within div.figure */ { /* Inherits div.figure props by default */ } /* ---- Code blocks and spans ---- */ pre, code { background-color: #fdf7ee; /* BEGIN word wrap */ /* Need all the following to word wrap instead of scroll box */ /* This will override the overflow:auto if present */ white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ /* END word wrap */ } pre /* Code blocks */ { /* Distinguish pre blocks from other text by more than the font with a background tint. */ padding: 0.5em; /* Since we have a background color */ border-radius: 5px; /* Softens it */ /* Give it a some definition */ border: 1px solid #aaa; /* Set it off left and right, seems to look a bit nicer when we have a background */ margin-left: 0.5em; margin-right: 0.5em; } pre.yacc, code.yacc { background-color: #f0f0f0; } pre.yacc /* Code blocks */ { /* Distinguish pre blocks from other text by more than the font with a background tint. */ padding: 0.0em; /* Since we have a background color */ border-radius: 5px; /* Softens it */ /* Give it a some definition */ border: 0px solid #aaa; /* Set it off left and right, seems to look a bit nicer when we have a background */ margin-left: 0.0em; margin-right: 0.0em; } @media screen { pre { white-space: pre; /* Dotted looks better on screen and solid seems to print better. */ border: 1px dotted #777; } } code /* All inline code spans */ { } p > code, li > code /* Code spans in paragraphs and tight lists */ { /* Pad a little from adjacent text */ padding-left: 2px; padding-right: 2px; } li > p code /* Code span in a loose list */ { /* We have room for some more background color above and below */ padding: 2px; } span.option { color: blue; text-decoration: underline; } /* ---- Math ---- */ span.math /* Pandoc inline math default and --jsmath inline math */ { /* Tried font-style:italic here, and it messed up MathJax rendering in some browsers. Maybe don't mess with at all. */ } div.math /* Pandoc --jsmath display math */ { } span.LaTeX /* Pandoc --latexmathml math */ { } eq /* Pandoc --gladtex math */ { } /* ---- Tables ---- */ /* A clean textbook-like style with horizontal lines above and below and under the header. Rows highlight on hover to help scanning the table on screen. */ table { border-collapse: collapse; border-spacing: 0; /* IE 6 */ border-bottom: 2pt solid #000; border-top: 2pt solid #000; /* The caption on top will not have a bottom-border */ /* Center */ margin-left: auto; margin-right: auto; } thead /* Entire table header */ { border-bottom: 1pt solid #000; background-color: #eee; /* Does this BG print well? */ } tr.header /* Each header row */ { } tbody /* Entire table body */ { } /* Table body rows */ tr { } tr.odd:hover, tr.even:hover /* Use .odd and .even classes to avoid styling rows in other tables */ { background-color: #eee; } /* Odd and even rows */ tr.odd {} tr.even {} td, th /* Table cells and table header cells */ { vertical-align: top; /* Word */ vertical-align: baseline; /* Others */ padding-left: 0.5em; padding-right: 0.5em; padding-top: 0.2em; padding-bottom: 0.2em; } /* Removes padding on left and right of table for a tight look. Good if thead has no background color*/ /* tr td:last-child, tr th:last-child { padding-right: 0; } tr td:first-child, tr th:first-child { padding-left: 0; } */ th /* Table header cells */ { font-weight: bold; } tfoot /* Table footer (what appears here if caption is on top?) */ { } caption /* This is for a table caption tag, not the p.caption Pandoc uses in a div.figure */ { caption-side: top; border: none; font-size: 0.9em; font-style: italic; text-align: center; margin-bottom: 0.3em; /* Good for when on top */ padding-bottom: 0.2em; } /* ---- Definition lists ---- */ dl /* The whole list */ { border-top: 2pt solid black; padding-top: 0.5em; border-bottom: 2pt solid black; } dt /* Definition term */ { font-weight: bold; } dd+dt /* 2nd or greater term in the list */ { border-top: 1pt solid black; padding-top: 0.5em; } dd /* A definition */ { margin-bottom: 0.5em; } dd+dd /* 2nd or greater definition of a term */ { border-top: 1px solid black; /* To separate multiple definitions */ } /* ---- Footnotes ---- */ a.footnote, a.footnoteRef { /* Pandoc, MultiMarkdown footnote links */ font-size: small; vertical-align: text-top; } a[href^="#fnref"], a.reversefootnote /* Pandoc, MultiMarkdown, ?? footnote back links */ { } @media print { a[href^="#fnref"], a.reversefootnote /* Pandoc, MultiMarkdown */ { /* Don't display these at all in print since the arrow is only something to click on */ display: none; } } div.footnotes /* Pandoc footnotes div at end of the document */ { } div.footnotes li[id^="fn"] /* A footnote item within that div */ { } table tr td,th { border-right: 1px solid; border-left: 1px solid; } /* You can class stuff as "noprint" to not print. Useful since you can't set this media conditional inside an HTML element's style attribute (I think), and you don't want to make another stylesheet that imports this one and adds a class just to do this. */ @media print { .noprint { display:none; } }
integration into IS ISO/IEC 9899:202y
document history n3393 202411 Original proposal n3414 202412 Motivate the two proposed normative changes Use the term ânumber of elementsâ Only refer to the different syntaxt rules as âformsâ Make it clearer that only one of the conditions for composite types is syntactic n3495 202502 Grammar and change marks, discuss_Lengthof
or similar license
CC BY, see https://creativecommons.org/licenses/by/4.0
MotivationThe current wording of 6.7.7.3 is very confusing because it mixes up syntactic and semantic definitions in several places. In particular it introduces a term âsize of an arrayâ in the constraints section that is not properly defined; it is not clear what âspecifiesâ means here. Later in the text even the case of a *
token, which is just one other syntax derivation, is seemingly subsumed with that term. So is it a syntax element (the assignment expression or *
token) or is it a semantic derivation (the value of that assignment expression, which does not exist for the *
case)?
We propose to iron out these issues by changing the text to use already introduced terms and to make a clearer distinction of where the text talks about syntactic deduction and where it introduces semantic for that syntax.
ApproachWe remove the confusing term âsize of an arrayâ by reverting its use to the one that appears in the syntax derivation, namely an assignment expression. Adding just this distinctive word in all places where the current text just talks about âexpressionâ, should make things clearer.
In particular when it comes to the definition of compatible types, the current text gives a definition that only applies sensibly to the syntactic constructs, and that lack a consistent lift to the semantics. So we change this definition of compatibility to refer to the syntax construct âarray declaratorâ (which is the subject of the clause) and only then lift this definition to array types in a second step.
Normative changesWe propose two normative changes which are not meant to change existing practice but to repair the standard such it matches existing practice. If any of these normative changes is not wanted by WG14, it can easily be omitted.
Using integer constant expression instead of constant expressionThe addition of the word integer in some places upgrading the term âconstant expressionâ to âinteger constant expressionâ (6.7.7.3 and J .2 item 72) is intended to be a normative change.
Discussion on the reflector has shown that the expressions here are meant to reflect a constraint at translation time and not a link time, and so we propose to rectify the text by this addition.
Completing incomplete array typesA change of semantics also occurs in 6.7.11 when changing the term âinitializer listâ to âinitializer or braced initializerâ. This is doubly motivated
We also add âor by an initializerâ in 6.2.5 p27, because without this the description is incomplete. The type of an identifier can be completed within the same definition, not only by additional declarations that have linkage that are provided later. Note that here adding âinitializerâ and not âbraced initializerâ is sufficient because that sentence is talking of declarations of identifiers. This addition does not change the normative contents of the text.
Suggested additions and changes to the wording.New text is underlined green, removed text is stroke-out red.
In 6.2.5 (Types)to 6.2.7, Compatible type and composite type27 An array type of unknown size number of elements is an incomplete type. It is completed, for an identifier of that type, by specifying the size in a later declaration (with internal or external linkage) or by an initializer, see 6.7.11. A structure or union type of unknown content (as described in 6.7.3.4) is an incomplete type. It is completed, for all declarations of that type, by declaring the same structure or union tag with its defining content later in the same scope.
in p3, second bullet
- If both types are array types, the following rules are applied:
to 6.7.7.3, Array declarators
- If one type is an array of known constant size and N elements, the composite type is an array of that size has N elements.
- Otherwise, if one type is a variable length array whose size is specified by an declarator has an assignment expression that is not evaluated, the behavior is undefined.
- Otherwise, if one type is a variable length array whose size is specified with N elements, the composite type is a variable length array of that size with N elements.
- Otherwise, if one type is a variable length array of unspecified size with an unspecified number of elements, the composite type is a variable length array of unspecified size with an unspecified number of elements.
- Otherwise, both array types are incomplete arrays of unknown size and the composite type is an incomplete array of unknown size type.
Constraints
1 In addition to optional type qualifiers and the keyword
static
, the[
and]
can delimit an assignment expression or a*
token. If they delimit an assignment expression (which specifies the size of an array), the expression it shall have an integer type. If the assignment expression is an integer constant expression, it shall have a value greater than zero. The element type shall not be an incomplete or function type. The optional type qualifiers and the keywordstatic
shall appear only in a declaration of a function parameter with an array type, and then only in the outermost array type derivation.
2 â¦
Semantics
3 â¦
4 If the size is not present In the first form, the array type has an unknown number of elements and is an incomplete type. If the size is * instead of being an expression In the fourth form, the array type is a variable length array type of unspecified size with an unspecified number of elements, which can only be used as part of the nested sequence of declarators or abstract declarators for a parameter declaration, not including anything inside an array size expression any array declarator of the second or third form in one of those declarators;161) such arrays are nonetheless complete types. Otherwise, if the assignment expression is evaluated its value is the number of elements of the array type (6.2.5); this value is subsequently also denoted by the terms size of an array or length of an array. If the size assignment expression is an integer constant expression and the element type has a known constant size, the array type is not a variable length array type; otherwise, the array type is a variable length array type. (Variable length arrays with automatic storage duration are a conditional feature that implementations may support; see 6.10.10.4.)
5 If the size is an assignment expression that is not an integer constant expression: if it occurs in a declaration at function prototype scope, it is treated as if it were replaced by a
*
token; otherwise, each time it is evaluated it shall have a value greater than zero. The size number of elements of each instance of a variable length array type does not change during its lifetime. Where a size the assignment expression is part of the operand of a typeof orsizeof
operator and changing the value of the size assignment expression would not affect the result of the operator, it is unspecified whether or not the size assignment expression is evaluated. Where a size an assignment expression is part of the operand of analignof
operator, that assignment expression is not evaluated.
6 For two array types to be compatible, both shall have compatible element types, and if both size specifiers are present, and are integer constant expressions, then both size specifiers shall have the same constant value for both the number of elements is specified, it shall be the same. If the two array types are used in a context which requires them to be compatible, the behavior is undefined if the two size specifiers evaluate to unequal values.
â¦
11 EXAMPLE 5 The following is invalid, because the use of
[*]
is inside an array size assignment expression of an array declarator rather than directly part of the nested sequence of abstract declarators for a parameter declaration:
void f(int (*)[sizeof(int (*)[*])]);
to 6.7.9, Type definitions
to 6.7.11, Initialization3 In a declaration whose storage-class specifier is
typedef
, each declarator defines an identifier to be a typedef name that denotes the type specified for the identifier in the way described in 6.7.7. Any array size assignment expressions associated with variable length array declarators and typeof operators are evaluated each time the declaration of the typedef name is reached in the order of execution. Atypedef
declaration does not introduce a new type, only a synonym for the type so specified. That is, in the following declarations: â¦
to 6.8.123 If an array of unknown size an incomplete array type is initialized, its size number of elements is determined by the largest indexed element with an explicit initializer. The array type is completed at the end of its initializer list (for array definitions) or braced initializer (for compound literals).
to 7.21.2, the unreachable macro4 A full expression is an expression that is not part of another expression, nor part of a declarator or abstract declarator. There is also an implicit full expression in which the non-constant size expressions for a variably modified type are an assignment expression of an array declarator that is not an integer constant expression is evaluated; within that full expression, the evaluation of different size assignment expressions of array declarators are unsequenced with respect to one another. There is a sequence point between the evaluation of a full expression and the evaluation of the next full expression to be evaluated.
In p4 make the following change
to J .1Here, the
static
array size adorned assignment expression of the array declarator and the annotation of the control flow withunreachable
indicates that the pointed-to parameter arrayargv
will hold at least three elements, regardless of the circumstances.
to J .2
- Whether a size expression an assignment expression of an array declarator is evaluated when it is part of the operand of a sizeof operator and changing the value of the size assignment expression would not affect the result of the operator (6.7.7.3)
- A program requires the formation of a composite type from a variable length array type whose size is specified by an from an array declarator with an assignment expression that is not evaluated (6.2.7).
- The size expression in an array declaration assignment expression of an array declarator is not a an integer constant expression and evaluates at program execution time to a nonpositive value (6.7.7.3).
Interaction with other proposals
- In a context requiring two array types to be compatible, they do not have compatible element types, or their size specifiers evaluate to unequal values their respective number of elements are specified but are not the same (6.7.7.3).
If n3499 is accepted concurrently, the additions of the word âassignmentâ above should instead read âreproducibleâ. Note that n3498 also proposes changes to 6.7.7.3, but that these are independent of each other.
Another interaction is with the whole discussion if we should have a term for the ânumber of elements of an arrayâ and what that term should be. If e.g we decide to stick to _Lengthof
or lengthof
, we could use âarray lengthâ throughout instead of âassignment expressionâ as proposed here. If we change the name of that operator to countof
, use âarray countâ, etc.
Thanks to Jakub Åukasiewicz, Joseph Myers, Javier Múgica and Robert Seacord for review and discussions.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4