From: Alejandro Colomar <alx+gcc@kernel.org>
To: gcc@gcc.gnu.org
Cc: "Mark Harris" <mark.hsj@gmail.com>,
"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>,
"Guillem Jover" <guillem@hadrons.org>,
g.branden.robinson@gmail.com,
"Günther Noack" <gnoack3000@gmail.com>,
"Ahelenia Ziemiańska" <nabijaczleweli@nabijaczleweli.xyz>,
linux-man@vger.kernel.org
Subject: -Wshadow=retroactive-parameter
Date: Fri, 23 Oct 2026 23:34:03 +0200 [thread overview]
Message-ID: <atvQDqWEqDAERpY5@debian> (raw)
[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]
Hi!
I'm worried about some proposal going on in the C Committee at the
moment, and which I've also received for the manual pages.
Some people would like manual pages to use retroactive declarations of
parameters. I fear that would cause all kinds of bugs if programmers
see that syntax and believe it's valid and has the intuitive meaning,
but then compile it and get behavior that might not be what they want.
In particular, I'm worried that this might happen rather often in the
near future:
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
I would be interested in having a new subflag
-Wshadow=retroactive-parameter, which triggers when a parameter is
shadowing a previous variable and that variable has been used previously
in the same parameter declaration list in which the shadowing parameter
is being declared (but before the shadowing occurs).
This should be part of -Wextra (at least), as it's rather dangerous, and
shouldn't break any existing code (if it triggers, the code is likely
bad).
This would remove my concerns about it.
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
reply other threads:[~2026-10-23 21:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=atvQDqWEqDAERpY5@debian \
--to=alx+gcc@kernel.org \
--cc=carlos@redhat.com \
--cc=chris.bazley.wg14@gmail.com \
--cc=g.branden.robinson@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=gnoack3000@gmail.com \
--cc=guillem@hadrons.org \
--cc=josmyers@redhat.com \
--cc=linux-man@vger.kernel.org \
--cc=mark.hsj@gmail.com \
--cc=mtk.manpages@gmail.com \
--cc=nabijaczleweli@nabijaczleweli.xyz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox