https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83463

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #7)
> (In reply to Jakub Jelinek from comment #4)
> > Ugh:
> >                   value_range_type rng = get_range_info (offset, &min, 
> > &max);
> >                   if (rng == VR_RANGE)
> >                     {
> >                       offrange[0] = min.to_shwi ();
> >                       offrange[1] = max.to_shwi ();
> >                     }
> >                   else if (rng == VR_ANTI_RANGE)
> >                     {
> >                       offrange[0] = (max + 1).to_shwi ();
> >                       offrange[1] = (min - 1).to_shwi ();
> >                     }
> > What guarantees that min or max fit into shwi?
> > Why the hops through shwi at all?  Just do:
> >   offrange[0] = offset_int (min, UNSIGNED);
> 
> How's this better?  It doesn't even compile.
> 
> I wrestled with how to convert wide_int to offset_int and couldn't come up
> with a way to do it,  I don't see why the API won't accept straight
> conversion from wide_int to offset_int.  Ugh indeed.

I meant offrange[0] = offset_int::from (min, UNSIGNED);, if you look at the
full comment, it mentions it just a few lines later in full.

The reason why wide-int.h doesn't allow straight conversion is that when you
have a wide_int, all you know is the precision from that object, but not
whether it is for unsigned or signed type, so you don't know whether to sign or
zero extend it if offset_int is wider.

Reply via email to