Hi,
> >> >> > Index: tree-vrp.c
> >> >> > ===================================================================
> >> >> > --- tree-vrp.c (revision 173703)
> >> >> > +++ tree-vrp.c (working copy)
> >> >> > @@ -2273,7 +2273,12 @@ extract_range_from_binary_expr (value_ra
> >> >> > {
> >> >> > /* For pointer types, we are really only interested in
> >> >> > asserting
> >> >> > whether the expression evaluates to non-NULL. */
> >> >> > - if (range_is_nonnull (&vr0) || range_is_nonnull (&vr1))
> >> >> > + if (flag_delete_null_pointer_checks && nowrap_type_p
> >> >> > (expr_type))
> >> >>
> >> >> the latter would always return true
> >> >>
> >> >> Btw, I guess you'll "miscompile" a load of code that is strictly
> >> >> undefined. So I'm not sure we want to do this against our users ...
> >> >
> >> > Probably not, at least unless the user explicitly asks for it -- for
> >> > example,
> >> > we could have -fdelete-null-pointer-checks=2. In fact, it might be a
> >> > good idea
> >> > to implement this flag anyway, since some current uses of
> >> > flag_delete_null_pointer_checks
> >> > can lead to "miscompilations" when user makes an error in their code and
> >> > would
> >> > probably appreciate more having their program crash.
> >> >
> >> >> Oh, and of course it's even wrong. I thing it needs &&
> >> >> !range_includes_zero (&vr1) (which we probably don't have). The
> >> >> offset may be 0 and NULL + 0
> >> >> is still NULL.
> >> >
> >> > actually, the result of NULL + 0 is undefined (pointer arithmetics is
> >> > only defined
> >> > for pointers to actual objects, and NULL cannot point to one).
> >>
> >> It's maybe undefined in C, but is it undefined in the middle-end? Thus,
> >> are you sure we never generate it from (void *)((uintptr_t)p +
> >> obfuscated_0)?
> >> I'm sure we simply fold that to p + obfuscated_0.
> >
> > if we do, we definitely should not -- the only point of such a construction
> > is
> > to bypass the pointer arithmetics restrictions,
>
> Ok, we don't. Where does the C standard say that NULL + 0 is undefined?
I don't think it explicitly states that it is undefined. But 6.5.6 #7 and #8
only
give semantics for pointers to objects,
Zdenek