*/ } 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; } }
2024-11-19
integration into IS ISO/IEC 9899:202y
document number | date | comment |
---|---|---|
n3393 | 202411 | Original proposal |
The 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.
We 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.
Note that only the addition of the word integer in some places (upgrading the term “constant expression” to “integer constant expression”) is intended to be a normative change, all other modifications should not change the semantics. If that one normative change is not wanted by WG14, it can easily be omitted.
New text is underlined green, removed text is
stroke-out red.
in p3, second bullet
- If both types are array types, the following rules are applied:
- If one type is an array of known constant size, the composite type is an array of that size.
- Otherwise, if one type is a variable length array whose
size is specified by andeclarator has an assignment expression that is not evaluated, the behavior is undefined.- Otherwise, if one type is a variable length array whose
size is specifieddeclarator has an assignment expression, the composite type is a variable length arrayof that sizewith a declarator that has an assignment expression with the same value.- Otherwise, if one type is a variable length array of unspecified size, the composite type is a variable length array of unspecified size.
- Otherwise, both types are arrays of unknown size and the composite type is an array of unknown size.
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 assignment expression 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 notneither an assignment expression nor the*
token are present, the array type is an incomplete type. If thesize is * instead of being an expression*
token is present, the array type is a variable length array type of unspecified size, which can only be used as part of the nested sequence of declarators or abstract declarators for a parameter declaration, not includinganything inside an array size expressionany assignment expression in one of those declarators;161) such arrays are nonetheless complete types. If an assignment expression is present and evaluated, its value is the number of elements of the instance of the array type; this value is consequently denoted by size or length or an array. Ifthe size expressionit 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 anassignment expressionthatis 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 of each instance of a variable length array type does not change during its lifetime. Wherea sizethe assignment expression is part of the operand of a typeof orsizeof
operator and changing the value of thesizeassignment expression would not affect the result of the operator, it is unspecified whether or not thesizeassignment expression is evaluated. Wherea sizethe assignment expression is part of the operand of analignof
operator, that assignment expression is not evaluated.
6 For two array
typesdeclarators to be compatible, both shall have compatible element types, and if bothsize specifiersassignment expressions are present, and are integer constant expressions, then bothsize specifiersassignment expressions shall have the same constant value. Two array types are compatible if the array declarators that gave raise to them are compatible. If the two arraytypesdeclarators are used or refered to in a context which requires them to be compatible, the behavior is undefined if the twosize specifiersassignment expressions evaluate to unequal values.
…
11 EXAMPLE 5 The following is invalid, because the use of
[*]
is inside anarray sizeassignment expression of and array declarator rather than directly part of the nested sequence of abstract declarators for a parameter declaration:
3 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. Anyarray sizeassignment 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: …
23 If an array of unknown size is initialized, its number of elements and indirectly its object size is determined by the largest indexed element with an explicit initializer. The array type is completed at the end of its initializer list.
4 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 sizean assignment expressionsfor a variably modified typeof an array declarator that is not an integer constant expression are evaluated; within that full expression, the evaluation of differentsizeassignment 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
Here, the
static
array sizeadorned assignment expression of the array declarator and the annotation of the control flow with unreachable indicates that the pointed-to parameter arrayargv
will hold at least three elements, regardless of the circumstances.
- Whether
a size expressionan assignment expression of an array declarator is evaluated when it is part of the operand of a sizeof operator and changing the value of thesizeassignment 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 anfrom an array declarator with an assignment expression that is not evaluated (6.2.7).
- The
size expression in an array declarationassignment expression of an array declarator is notaan integer constant expression and evaluates at program execution time to a nonpositive value (6.7.7.3).
- In a context requiring two array types to be compatible, they do not have compatible element types, or
their size specifiersthe assignment expressions of their declarators evaluate to unequal values (6.7.7.3).
If n3392 is accepted concurrently, the additions of the word “assignment” above should instead read “reproducible”. Note that n3391 also proposes changes to 6.7.7.3, but that these are independent of each other.
Thanks to Jakub Łukasiewicz for compiling a list of possible places that could be impacted by this change.