[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXdi1kl_wHMFJRFQ@devuan>
Date: Mon, 26 Jan 2026 13:49:29 +0100
From: Alejandro Colomar <alx@...nel.org>
To: Martin Uecker <uecker@...raz.at>,
Christopher Bazley <chris.bazley.wg14@...il.com>, Alex Celeste <alexg.nvfp@...il.com>,
Joseph Myers <josmyers@...hat.com>, Aaron Ballman <aaron@...onballman.com>
Cc: Douglas McIlroy <douglas.mcilroy@...tmouth.edu>,
Bruno Haible <bruno@...sp.org>, Paul Eggert <eggert@...ucla.edu>,
Florian Weimer <fweimer@...hat.com>, Jonathan Corbet <corbet@....net>, Kees Cook <kees@...nel.org>,
Eric Biggers <ebiggers@...nel.org>, Ard Biesheuvel <ardb@...nel.org>,
Daniel Thompson <danielt@...nel.org>, Daniel Lundin <daniel.lundin.mail@...il.com>,
"Valentin V. Bartenev" <vbartenev@...il.com>, Andrew Clayton <andrew@...ital-domain.net>,
"Brian W. Kernighan" <bwk@...princeton.edu>, "G. Branden Robinson" <branden@...ian.org>,
"Basil L. Contovounesios" <basil@...tovou.net>, "Jason A. Donenfeld" <jason@...c4.com>,
Linus Torvalds <torvalds@...ux-foundation.org>, onf <onf@...root.org>, Rich Felker <dalias@...c.org>,
linux-hardening@...r.kernel.org, Alejandro Colomar <alx@...nel.org>
Subject: [RFC v3 6/6] alx-0080r1 - [static] without array length expression
Name
alx-0080r1 - [static] without array length expression
Principles
- Keep the language small and simple
Category
Language; array parameters.
Author
Alejandro Colomar <alx@...nel.org>
Cc: Martin Uecker <uecker@...raz.at>
Acked-by: Doug McIlroy
Acked-by: Andrew Clayton <ac@...segv.uk>
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>
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists