On Tue, Jan 16, 2018 at 01:36:26PM -0700, Martin Sebor wrote:
> --- gcc/gimple-ssa-warn-restrict.c (revision 256752)
> +++ gcc/gimple-ssa-warn-restrict.c (working copy)
> @@ -384,6 +384,12 @@ builtin_memref::builtin_memref (tree expr, tree si
> base = SSA_NAME_VAR (base);
> }
>
> + if (DECL_P (base) && TREE_CODE (TREE_TYPE (base)) == ARRAY_TYPE)
> + {
> + if (offrange[0] < 0 && offrange[1] > 0)
> + offrange[0] = 0;
> + }
Why the 2 nested ifs?
> @@ -1079,14 +1085,35 @@ builtin_access::strcat_overlap ()
> return false;
>
> /* When strcat overlap is certain it is always a single byte:
> - the terminatinn NUL, regardless of offsets and sizes. When
> + the terminating NUL, regardless of offsets and sizes. When
> overlap is only possible its range is [0, 1]. */
> acs.ovlsiz[0] = dstref->sizrange[0] == dstref->sizrange[1] ? 1 : 0;
> acs.ovlsiz[1] = 1;
> - acs.ovloff[0] = (dstref->sizrange[0] + dstref->offrange[0]).to_shwi ();
> - acs.ovloff[1] = (dstref->sizrange[1] + dstref->offrange[1]).to_shwi ();
You use to_shwi many times in the patch, do the callers or something earlier
in this function guarantee that you aren't throwing away any bits (unlike
tree_to_shwi, to_shwi method doesn't ICE, just throws away upper bits).
Especially when you perform additions like here, even if both wide_ints fit
into a shwi, the result might not.
Jakub