Name
alx-0080r1 - [static] without array length expression
Principles
- Keep the language small and simple
Category
Language; array parameters.
Author
Alejandro Colomar <[email protected]>
Cc: Martin Uecker <[email protected]>
Acked-by: Doug McIlroy
Acked-by: Andrew Clayton <[email protected]>
History
<https://www.alejandro-colomar.es/src/alx/alx/std/wg14/alx-0080.git/>
r0 (2026-01-25):
- Initial draft.
r1 (2026-01-26):
- Acked-by.
- tfix
Abstract
'static' in [static n] means that the argument shall be
non-null. That is entirely independent of the length of the
array parameter, so it doesn't make sense requiring the length
to be specified. Lift that restriction.
Discussion
While the standard, for a long time, claimed that 'static' in
[static n] was about the length of the array, it is well known
that this is only true in paper. In practice, programmers use
[n] with that meaning.
'static' in [static n] has a different meaning (see also
alx-0079): it says that the argument shall be non-null.
See also
<https://www.alejandro-colomar.es/src/alx/alx/std/wg14/alx-0079.git/>
alx-0079 ("[static n] == non-null [n]")
alx-0079 should be applied before alx-0080. Otherwise, the
semantics would be undefined.
Comments
On 2026-01-25T18:19:02-0500, Douglas McIlroy wrote:
> All six proposals look eminently reasonable. They simplify
> the language and remove surprises. I suspect these proposals
> will invalidate very few existing programs. In any event, the
> required corrections will improve the legibility and
> maintainability of such programs.
>
> Doug McIlroy
---
On 2026-01-26T02:01:16+0000, Alex Celeste wrote:
> Like Martin - these all seem eminently reasonable to me.
Proposed wording
Based on N3685.
6.7.7.1 Declarators :: General
@@ Syntax, p1
+array-qualifier-list:
+ <b>static</b>(opt) type-qualifier-list
+ type-qualifier-list <b>static</b>
+
+array-length-declarator:
+ assignment-expression
+ <b>*</b>
+
array-declarator:
- direct-declarator <b>[</b> type-qualifier-list(opt)
assignment-expression(opt) <b>]</b>
- direct-declarator <b>[ static</b> type-qualifier-list(opt)
assignment-expression <b>]</b>
- direct-declarator <b>[</b> type-qualifier-list <b>static</b>
assignment-expression <b>]</b>
- direct-declarator <b>[</b> type-qualifier-list(opt) <b>* ]</b>
+ direct-declarator <b>[</b> array-qualifier-list(opt)
array-length-declarator(opt) <b>]</b>
--
<https://www.alejandro-colomar.es>
signature.asc
Description: PGP signature
