From: Richard Biener <richard.guenther@gmail.com>
To: Eric Botcazou <botcazou@adacore.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix bogus -Wstringop-overflow warning in Ada
Date: Fri, 19 Aug 2022 09:30:13 +0200 [thread overview]
Message-ID: <CAFiYyc35RyeDPnRkTSU_sWGD2EcMmOxRVcbeAj-G9aGj9E9obA@mail.gmail.com> (raw)
In-Reply-To: <3120260.5fSG56mABF@arcturus>
On Thu, Aug 18, 2022 at 4:46 PM Eric Botcazou <botcazou@adacore.com> wrote:
>
> > Hmm :/ But that means we _should_ force a sign extension but only
> > from ptrofftype_p ()? That is, your test above should maybe read
> >
> > signop sgn = TYPE_SIGN (type);
> > if (ptrofftype_p (type))
> > sgn = SIGNED;
> >
> > assuming 'type' is the type of lowbnd
>
> Yes, that's essentially equivalent to what get_offset_range does, but I'm not
> sure why having two slightly different ways of doing it would be better than a
> single one here, Maybe replace the call to get_precision in both places with
> TYPE_PRECSION (type) then?
I wasn't aware of the copy in get_offset_range. To cite:
wide_int wr[2];
if (!get_range (x, stmt, wr, rvals))
return false;
signop sgn = SIGNED;
/* Only convert signed integers or unsigned sizetype to a signed
offset and avoid converting large positive values in narrower
types to negative offsets. */
if (TYPE_UNSIGNED (type)
&& wr[0].get_precision () < TYPE_PRECISION (sizetype))
sgn = UNSIGNED;
r[0] = offset_int::from (wr[0], sgn);
r[1] = offset_int::from (wr[1], sgn);
I guess the main issue here is that the machinery converts to offset_int
prematurely and thus needs to do it even when it's not clear in what context
(POINTER_PLUS_EXPR offset or not) it is used. The code unfortunately
is a bit of a mess and I'm not too familiar with it. I'm OK with your
original patch, given the above it's consistent (even if maybe broken).
Thanks,
Richard.
>
> --
> Eric Botcazou
>
>
>
prev parent reply other threads:[~2022-08-19 7:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 13:56 Eric Botcazou
2022-08-17 11:27 ` Richard Biener
2022-08-17 13:38 ` Eric Botcazou
2022-08-18 7:30 ` Richard Biener
2022-08-18 7:55 ` Eric Botcazou
2022-08-18 9:22 ` Richard Biener
2022-08-18 14:47 ` Eric Botcazou
2022-08-19 7:30 ` Richard Biener [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=CAFiYyc35RyeDPnRkTSU_sWGD2EcMmOxRVcbeAj-G9aGj9E9obA@mail.gmail.com \
--to=richard.guenther@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).