Name
	n4018, alx-0080r5 - [static] without array length expression

Principles
	-  Keep the language small and simple

Category
	Language; array parameters.

Author
	Alejandro Colomar <alx@kernel.org>

	Cc: Martin Uecker <uecker@tugraz.at>
	Cc: Halalaluyafail3 <luigighiron@gmail.com>
	Cc: Joseph Myers <josmyers@redhat.com>
	Acked-by: Doug McIlroy
	Acked-by: Andrew Clayton <ac@sigsegv.uk>
	Acked-by: onf <onf@disroot.org>
	Acked-by: Alex Celeste <alexg.nvfp@gmail.com>

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

	r2 (2026-02-01; n3803):
	-  Acked-by.

	r2bis (2026-10-25; n4015):
	-  Do not depend on alx-0079.
	-  Rebase on latest draft.
	-  Update abstract declarators too.
	-  Update (simplify) 6.7.7.3.

	r3 (2026-10-26):
	-  Use 'shall' for describing UB.  [Halalaluyafail3]
	-  Add (opt) to 2nd line of syntax of array-qualifier-list.  [H]
	-  Say specifically 'null pointer', since it's the only case of
	   an invalid pointer that this keyword controls.  [H]
	-  Remove superfluous 'then'.

	r4 (2026-10-26):
	-  Rebase on n3998.
	-  Add missing paragraph number.
	-  Document removal of 'then' in r3.
	-  Add 'then for each call ...', as in the existing text.

	r5 (2026-10-29; n4018):
	-  Reword 'appears within'.  [Joseph]

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.

	Let's allow programmers to use that meaning without having to
	use a dummy 1 (which is actually bad for safety).

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 N3998.
	
    6.7.7.1  Declarators :: General
	@@ Syntax, p1
	+array-qualifier-list:
	+	<b>static</b>(opt) type-qualifier-list
	+	type-qualifier-list(opt) <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>
	
    6.7.7.3  Array declarators
	@@ Semantics, p3
	 If, in the declaration "T D1",
	-D1 has one of the forms:
	+D1 has the form:
	-	D <b>[</b> type-qualifier-list(opt) assignment-expression(opt) <b>]</b> attribute-specifier-sequence(opt)
	-	D <b>[ static</b> type-qualifier-list(opt) assignment-expression <b>]</b> attribute-specifier-sequence(opt)
	-	D <b>[</b> type-qualifier-list <b>static</b> assignment-expression <b>]</b> attribute-specifier-sequence(opt)
	-	D <b>[</b> type-qualifier-list(opt) <b>* ]</b> attribute-specifier-sequence(opt)
	+	D <b>[</b> array-qualifier-list(opt) array-length-declarator(opt) <b>]</b> attribute-specifier-sequence(opt)
	...
	
    6.7.7.4  Function declarators
	@@ Semantics, p7
	 A declaration of a parameter as "array of type"
	 shall be adjusted to "qualified pointer to type",
	 where the type qualifiers (if any)
	 are those specified
	-within the [ and ] of the array type derivation.
	+in the array qualifier list.
	+If the array qualifier list
	+contains the keyword <b>static</b>,
	+then for each call to the function,
	+the value of the corresponding actual argument
	+shall not be a null pointer.
	-If the keyword <b>static</b> also appears
	-within the [ and ] of the array type derivation,
	+If the array qualifier list
	+contains the keyword <b>static</b>,
	+and the array length declarator
	+is an expression,
	 then for each call to the function,
	 the value of the corresponding actual argument
	 shall provide access to the first element of an array
	 with at least as many elements as specified
	 by the array length expression.
	
	## Now that we have array-qualifier-list and
	## array-length-declarator, we can use better wording than
	## the old 'appears within'.
	
    6.7.8  Type names
	@@ Syntax, p1
	 array-abstract-declarator:
	-	direct-abstract-declarator <b>[</b> type-qualifier-list(opt) assignment-expression(opt) <b>]</b>
	-	direct-abstract-declarator <b>[ static</b> type-qualifier-list(opt) assignment-expression <b>]</b>
	-	direct-abstract-declarator <b>[</b> type-qualifier-list <b>static</b> assignment-expression <b>]</b>
	-	direct-abstract-declarator <b>[</b> type-qualifier-list(opt) <b>* ]</b>
	+	direct-abstract-declarator <b>[</b> array-qualifier-list(opt) array-length-declarator(opt) <b>]</b>