On 01/02/2018 07:25 AM, Richard Biener wrote:
On Mon, Jan 1, 2018 at 11:30 PM, Martin Sebor <mse...@gmail.com> wrote:
PR tree-optimization/83640 - ice in generic_overlap at
gimple-ssa-warn-restrict.c:814 highlights out a class of cases
where the -Wrestrict checker assumes that the range of a pointer
offset that us represented by a VR_RANGE has a lower bound that
is less than its upper bound.  The pass asserts that this is so
and cases to the contrary trigger an ICE.

The submitted test case that triggers this ICE is due to a missed
optimization in tree-ssa-strlen (which could, and IMO should,
guarantee that the offsets it constructs are in such a range, and
I'll submit a separate patch with that change), but the assumption
isn't safe in general for offsets whose range happens to straddle
the PTRDIFF_MAX boundary, i.e., whose lower bound is greater than
its upper bound.

The attached patch makes adjustments to remove this assumption
and avoid the ICE.  Tested on x86_64-linux with no regressions.

Isn't the error you are using HOST_WIDE_INT rather than offset_int
for sizrange/ovloff/ovlsiz in builtin_access?

The classes work on offset_int.  Ultimately, they have to
convert to HOST_WIDE_INT before printing warnings because
there is no format directive to format wide ints, but
the HOST_WIDE_INT isn't the cause of the ICE.

The ICE is due to very large positive offsets (> PTRDIFF_MAX)
being negative.  The pass tries to handle these cases (where
a lower bound is positive but the upper bound negative) but
the handling is incomplete.  The patch completes it.

Martin


Martin

PS The patch also removes the same troublesome assertion that's
also removed in the one below:

  https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01399.html

Reply via email to