This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR 86572
- From: Jeff Law <law at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 4 Nov 2018 11:02:45 -0700
- Subject: Re: [PATCH] Fix PR 86572
- References: <VI1PR0701MB2862DEE3CE9F931132E8ECDDE4F40@VI1PR0701MB2862.eurprd07.prod.outlook.com>
On 10/22/18 9:08 AM, Bernd Edlinger wrote:
> Hi!
>
> This makes c_strlen avoid an unsafe strlen folding of const arguments
> with non-const offset. Currently a negative out of bounds offset
> makes the strlen function return an extremely large number, and
> at the same time, prevents the VRP machinery, to determine the correct
> range if the strlen function in this case.
>
> Fixed by doing the whole computation in size_t and casting the
> result back to ssize_t.
>
>
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
>
>
> Thanks
> Bernd.
>
>
> patch-pr86572.diff
>
> gcc:
> 2018-10-22 Bernd Edlinger <bernd.edlinger@hotmail.de>
>
> PR tree-optimization/86572
> * builtins.c (c_strlen): Handle negative offsets in a safe way.
>
> testsuite:
> 2018-10-22 Bernd Edlinger <bernd.edlinger@hotmail.de>
>
> PR tree-optimization/86572
> * gcc.dg/pr86572.c: New test.
OK.
jeff