This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: VR_RANGE with inverted bounds


On October 7, 2016 6:49:39 PM GMT+02:00, Martin Sebor <msebor@gmail.com> wrote:
>While processing the (p += i) expression below to validate the bounds
>of the pointer in I call get_range_info for i (in tree-object-size.c).
>The function returns the following VR_RANGE: [2147483648, -2147483649]
>rather than the expected [0, 1].  Is such a range to be expected or
>is it a bug?

This range is not valid (unless unsigned and you show it as signed).

>In general, what assumptions can I safely make about the bounds for
>VR_RANGE and VR_ANTI_RANGE?  For example, besides being inverted like
>in this example, can the bounds also ever be the same?  I don't think
>I have seen them be the same but I think I have seen a case where the
>variable's effective range was [X, X] (i.e., it was equal to
>a constant) and get_range_info returned VR_VARYING.  Should that also
>be expected?

Tree-vrp. Has various assertions in its lattice update function which should hold for all ranges.

Richard.

>Thanks
>Martin
>
>   void g (char *p, int i)
>   {
>     if (i < 0 || 1 < i)
>       i = 0;
>
>     p += i;
>     ...
>   }



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]