From: Martin Uecker <uecker@tugraz.at>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>, gcc-patches@gcc.gnu.org
Cc: Joseph Myers <joseph@codesourcery.com>
Subject: Re: [C PATCH]: Add Walloc-type to warn about insufficient size in allocations
Date: Mon, 31 Jul 2023 22:06:44 +0200 [thread overview]
Message-ID: <5e7e4be39deeedf52496f939cb4616a1066d5e10.camel@tugraz.at> (raw)
In-Reply-To: <9a779b3b-f576-90db-ab86-efc53a264592@gotplt.org>
Am Montag, dem 31.07.2023 um 15:39 -0400 schrieb Siddhesh Poyarekar:
> On 2023-07-21 07:21, Martin Uecker via Gcc-patches wrote:
> >
> >
> > This patch adds a warning for allocations with insufficient size
> > based on the "alloc_size" attribute and the type of the pointer
> > the result is assigned to. While it is theoretically legal to
> > assign to the wrong pointer type and cast it to the right type
> > later, this almost always indicates an error. Since this catches
> > common mistakes and is simple to diagnose, it is suggested to
> > add this warning.
> >
...
> >
>
> Wouldn't this be much more useful in later phases with ranger feedback
> like with the warn_access warnings? That way the comparison won't be
> limited to constant sizes.
Possibly. Having it in the FE made it simple to implement and
also reliable. One thing I considered is also looking deeper
into the argument and detect obvious mistakes, e.g. if the
type in a sizeof is the right one. Such extensions would be
easier in the FE.
But I wouldn't mind replacing or extending this with something
smarter emitted from later phases. I probably do not have time
to work on this is myself in the near future though.
Martin
next prev parent reply other threads:[~2023-07-31 20:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 11:21 Martin Uecker
2023-07-21 20:55 ` Qing Zhao
2023-07-31 19:39 ` Siddhesh Poyarekar
2023-07-31 20:06 ` Martin Uecker [this message]
2023-07-31 20:41 ` Prathamesh Kulkarni
2023-08-01 7:51 ` Martin Uecker
2023-08-01 13:27 ` Qing Zhao
2023-08-01 14:31 ` Martin Uecker
2023-08-02 16:45 ` Qing Zhao
2023-08-02 17:55 ` 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=5e7e4be39deeedf52496f939cb4616a1066d5e10.camel@tugraz.at \
--to=uecker@tugraz.at \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
--cc=siddhesh@gotplt.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).