From: Joseph Myers <joseph@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Marek Polacek <polacek@redhat.com>,
Jason Merrill <jason@redhat.com>,
Richard Biener <rguenther@suse.de>,
Martin Uecker <uecker@tugraz.at>, <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c: Split -Wcalloc-transposed-args warning from -Walloc-size, -Walloc-size fixes
Date: Tue, 19 Dec 2023 19:32:16 +0000 [thread overview]
Message-ID: <dbb09ee3-43cd-ae4c-4736-365826b64827@codesourcery.com> (raw)
In-Reply-To: <ZYCaIpyzJkqFTJBq@tucnak>
On Mon, 18 Dec 2023, Jakub Jelinek wrote:
> Hi!
>
> The following patch changes -Walloc-size warning to no longer warn
> about int *p = calloc (1, sizeof (int));, because as discussed earlier,
> the size is IMNSHO sufficient in that case, for alloc_size with 2
> arguments warns if the product of the 2 arguments is insufficiently small.
>
> Also, it warns also for explicit casts of malloc/calloc etc. calls
> rather than just implicit, so not just
> int *p = malloc (1);
> but also
> int *p = (int *) malloc (1);
>
> It also fixes some ICEs where the code didn't verify the alloc_size
> arguments properly (Walloc-size-5.c testcase ICEs with vanilla trunk).
>
> And lastly, it introduces a coding style warning, -Wcalloc-transposed-args
> to warn for calloc (sizeof (struct S), 1) and similar calls (regardless
> of what they are cast to, warning whenever first argument is sizeof and
> the second is not).
>
> Ok for trunk if this passes bootstrap/regtest?
OK.
--
Joseph S. Myers
joseph@codesourcery.com
prev parent reply other threads:[~2023-12-19 19:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-18 19:14 Jakub Jelinek
2023-12-19 7:11 ` Martin Uecker
2023-12-19 8:47 ` Jakub Jelinek
2023-12-19 10:34 ` Martin Uecker
2023-12-19 17:20 ` Jason Merrill
2023-12-19 17:45 ` Martin Uecker
2023-12-19 19:32 ` Joseph Myers [this message]
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=dbb09ee3-43cd-ae4c-4736-365826b64827@codesourcery.com \
--to=joseph@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=jason@redhat.com \
--cc=polacek@redhat.com \
--cc=rguenther@suse.de \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).