On 9/3/21 10:41 AM, Aldy Hernandez wrote:
[Andrew, do you see any problem with using the minus relational code
here?  It seems like everything matches up.]

I've seen cases in the upcoming jump threader enhancements where we see
a difference of two pointers that are known to be equivalent, and yet we
fail to return 0 for the range.  This is because we have no working
range-op entry for POINTER_DIFF_EXPR.  The entry we currently have is
a mere placeholder to avoid ignoring POINTER_DIFF_EXPR's so
adjust_pointer_diff_expr() could get a whack at it here:

//      def = __builtin_memchr (arg, 0, sz)
//      n = def - arg
//
// The range for N can be narrowed to [0, PTRDIFF_MAX - 1].

In theory... but do the non-equality relations make sense?   ie ptr1 < ptr2   ?   Perhaps there is no harm in those..  Probably undefined behaviour if they are not related so we can do whatever...


Andrew

Reply via email to