https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98255
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #8) > 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. Note all the above "mess" is due to FEs behaving oddly, notably different from just interpreting the index as-is (appropriately sign or zero-extending it to sizetype for the sizetype offset compute). The odd sign-extension is from gb48e22b2bd02
