From: Alejandro Colomar <alx.manpages@gmail.com>
To: GCC <gcc@gcc.gnu.org>
Subject: [wish] -Wmissing-array-initializers
Date: Tue, 14 Feb 2023 12:33:11 +0100 [thread overview]
Message-ID: <45c736ca-8f14-8e85-23dc-e1cb577e395e@gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 886 bytes --]
Hi!
I was wondering if we can have a warning similar to -Wmissing-field-initializers but for arrays.
Here's some example of what kind of code would benefit from this warning:
// foo.c
char *foo[5] = {
"foo",
"bar",
"baz"
// oops, accidentally the size doesn't match the actual number of fields
};
// foo.h
extern char *foo[5];
Users should be able to trust that each field will be a valid string,
but we have no way to make sure that the array is initialized with strings.
If the initialization is done through designated initializers [...]=..., or {0}, it wouldn't warn, as with structs.
I couldn't find an open ticket in bugzilla regarding this. If you want, I could open one.
Does it make sense to you?
Cheers,
Alex
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
reply other threads:[~2023-02-14 11:33 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=45c736ca-8f14-8e85-23dc-e1cb577e395e@gmail.com \
--to=alx.manpages@gmail.com \
--cc=gcc@gcc.gnu.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).