From: Alejandro Colomar <alx+linux-man@kernel.org>
To: Mark Harris <mark.hsj@gmail.com>
Cc: linux-man@vger.kernel.org,
Michael Kerrisk <mtk.manpages@gmail.com>,
Christopher Bazley <chris.bazley.wg14@gmail.com>,
Sam James <sam@gentoo.org>, Carlos O'Donell <carlos@redhat.com>,
"Joseph S. Myers" <josmyers@redhat.com>,
Martin Uecker <uecker@tugraz.at>
Subject: Re: [PATCH] man/: SYNOPSIS: Remove GNU forward-declarations of parameters for lengths of array parameters
Date: Fri, 23 Oct 2026 22:06:00 +0200 [thread overview]
Message-ID: <atu86HJu42lNGA7z@debian> (raw)
In-Reply-To: <CAMdZqKH=pJUf4kvHNKaPMzdznajxS6EWTn2cXnTqT2ttjithbw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2525 bytes --]
Hi Mark,
> Date: 2026-10-23 12:32:37-0700
> From: Mark Harris <mark.hsj@gmail.com>
>
[...]
>
> I am not talking about someone writing new code that they will then
> try to compile at some point, I am talking about someone trying to
> understand or debug existing code.
>
[...]
> trying to debug what is happening. The man pages should do what it
> can to help them, not throw monkey wrenches in their path.
I see your concern.
> > You didn't take into account my other concerns, though. I'd like to
> > hear your opinion about the concerns that letting users think that is
> > valid C might lead to them writing code that has UB (or logic errors).
>
> An error in thinking that this is valid C syntax doesn't impact anyone
> trying to understand existing code, so I don't see the concerns as
> comparable.
It is actually valid syntax already. It doesn't have the meaning that
we would be using for it, but it's valid syntax.
int n = 42;
int f(char a[n], int n);
f(a, 7);
The array parameter is declared to have 42 elements, regardless of the
7 used at call site.
> If someone adds this in their own C code, and it has not been adopted
> as valid ISO C
The code above is valid C89, and it doesn't mean what one would
intuitively think it means. That's my concern. This is a source of
bugs.
Future extensions to the language will make that even more dangerous, by
making it more likely to compile:
alx@debian:~/tmp$ cat param.c
int
main(void)
{
int n = 42;
int f(char a[n], int n)
{
return _Countof(a);
}
char s[] = "foo";
return f(s, _Countof(s));
}
alx@debian:~/tmp$ /opt/local/gnu/gcc/cap/bin/gcc -Wall -Wextra param.c
param.c: In function ‘f’:
param.c:6:30: warning: unused parameter ‘n’ [-Wunused-parameter]
6 | int f(char a[n], int n)
| ~~~~^
alx@debian:~/tmp$ ./a.out; echo $?
42
> or as a compiler extension, then it is extremely likely
> to result in a compiler error. If a likely compiler error was good
> enough for you when someone writes the arguments in the wrong order in
> their code due to confusion over the syntax, then I don't see why it
> wouldn't be satisfactory in this case where a compiler error is even
> more likely. In both cases there is a chance that it will be accepted
> and do the wrong thing.
This analysis is wrong. See above.
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-10-23 20:06 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 16:44 [PATCH] man/: SYNOPSIS: Remove GNU forward-declarations of parameters for lengths of array parameters Alejandro Colomar
2026-10-22 17:11 ` Martin Uecker
2026-10-22 20:01 ` Alejandro Colomar
2026-10-22 20:27 ` Alejandro Colomar
2026-10-22 17:37 ` Christopher Bazley
[not found] ` <CAEHU8x9jET+vcrR0NpDz6t57egQG8TZqx5XtV52srH9ZRvdxSQ@mail.gmail.com>
2026-10-22 19:54 ` Alejandro Colomar
2026-10-23 11:53 ` Michael Kerrisk (man7.org)
2026-10-23 12:42 ` Alejandro Colomar
2026-10-23 15:51 ` Christopher Bazley
2026-10-24 12:45 ` Michael Kerrisk (man7.org)
2026-10-24 13:38 ` Alejandro Colomar
2026-10-24 16:16 ` Christopher Bazley
2026-10-24 16:37 ` Alejandro Colomar
2026-10-24 18:11 ` Martin Uecker
2026-10-25 6:59 ` Alejandro Colomar
2026-10-25 7:22 ` Martin Uecker
2026-10-25 7:38 ` Alejandro Colomar
2026-10-25 8:29 ` G. Branden Robinson
2026-10-25 8:40 ` Martin Uecker
2026-10-25 8:57 ` Alejandro Colomar
2026-10-25 9:05 ` Martin Uecker
2026-10-29 21:24 ` Christopher Bazley
2026-10-29 22:57 ` Alejandro Colomar
2026-10-23 12:11 ` Alejandro Colomar
2026-10-22 22:03 ` Mark Harris
2026-10-23 9:43 ` Alejandro Colomar
2026-10-23 19:32 ` Mark Harris
2026-10-23 20:06 ` Alejandro Colomar [this message]
2026-10-24 7:53 ` Martin Uecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=atu86HJu42lNGA7z@debian \
--to=alx+linux-man@kernel.org \
--cc=carlos@redhat.com \
--cc=chris.bazley.wg14@gmail.com \
--cc=josmyers@redhat.com \
--cc=linux-man@vger.kernel.org \
--cc=mark.hsj@gmail.com \
--cc=mtk.manpages@gmail.com \
--cc=sam@gentoo.org \
--cc=uecker@tugraz.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.