From: Jeff Law <jeffreyalaw@gmail.com>
To: Eric Botcazou <botcazou@adacore.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix bogus -Wstringop-overflow warning
Date: Thu, 13 Oct 2022 16:31:19 -0600 [thread overview]
Message-ID: <f789c717-2f97-4d3a-bc77-d476f0e20eb5@gmail.com> (raw)
In-Reply-To: <3194055.aeNJFYEL58@fomalhaut>
On 10/13/22 06:06, Eric Botcazou via Gcc-patches wrote:
> Hi,
>
> if you compile the attached testcase with -O2 -fno-inline -Wall, you get:
>
> In function 'process_array3':
> cc1: warning: 'process_array4' accessing 4 bytes in a region of size 3 [-
> Wstringop-overflow=]
> cc1: note: referencing argument 1 of type 'char[4]'
> t.c:6:6: note: in a call to function 'process_array4'
> 6 | void process_array4 (char a[4], int n)
> | ^~~~~~~~~~~~~~
> cc1: warning: 'process_array4' accessing 4 bytes in a region of size 3 [-
> Wstringop-overflow=]
> cc1: note: referencing argument 1 of type 'char[4]'
> t.c:6:6: note: in a call to function 'process_array4'
>
> That's because the ICF IPA pass has identified the two functions and turned
> process_array3 into a wrapper of process_array4. This looks sensible to me
> given that the only difference between them is an "access" attribute on their
> type describing the access size of the parameter and the "access" attribute
> does not affect type identity (struct attribute_spec.affects_type_identity).
>
> Hence the proposed fix, tested on x86-64/Linux, OK for the mainline?
>
>
> 2022-10-13 Eric Botcazou <ebotcazou@adacore.com>
>
> * gimple-ssa-warn-access.cc (pass_waccess::check_call): Return
> early for calls made from thunks.
>
>
> 2022-10-13 Eric Botcazou <ebotcazou@adacore.com>
>
> * gcc.dg/Wstringop-overflow-89.c: New test.
Not a fan as it could potentially hide a real issue, but I don't really
have a better solution. I pondered suggesting "access" affect type
identity, but the cases where that's really important are probably
better handled by the "fn spec" attribute, leaving "access" strictly
impacting diagnostics.
OK
jeff
next prev parent reply other threads:[~2022-10-13 22:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 12:06 Eric Botcazou
2022-10-13 22:31 ` Jeff Law [this message]
2022-10-13 22:53 ` Eric Botcazou
2022-10-14 6:12 ` Richard Biener
2022-10-14 10:27 ` Martin Liška
2022-10-14 11:59 ` Martin Jambor
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=f789c717-2f97-4d3a-bc77-d476f0e20eb5@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=botcazou@adacore.com \
--cc=gcc-patches@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).