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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
503                     poly_offset_int woffset
504                       = wi::sext (wi::to_poly_offset (index)
505                                   - wi::to_poly_offset (low_bound),
506                                   TYPE_PRECISION (TREE_TYPE (index)));
in get_ref_base_and_extent indeed looks incorrect to me, for precisions smaller
than precision of pointer (or is that sizetype) I think we need to sign or zero
extend based on whether index has signed or unsigned type.
For arrays with zero low_bound I think what get_inner_reference does is right,
in particular:
            offset = size_binop (PLUS_EXPR, offset,
                                 size_binop (MULT_EXPR,
                                             fold_convert (sizetype, index),
                                             unit_size));
For non-zero low_bound, it does:
            if (! integer_zerop (low_bound))
              index = fold_build2 (MINUS_EXPR, TREE_TYPE (index),
                                   index, low_bound);
before that and I'm surprised that it assumes index and low_bound will be
compatible types.  But perhaps they are in the languages that do support
non-zero low bounds.

Reply via email to