https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102043
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ebotcazou at gcc dot gnu.org --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- For this testcase the bogus ref is constructed by conv_array_index_offset: /* Read the vector to get an index into info->descriptor. */ data = build_fold_indirect_ref_loc (input_location, gfc_conv_array_data (desc)); index = gfc_build_array_ref (data, index, NULL); where ultimatively gfc_conv_descriptor_data_get is what builds the base the ARRAY_REF is applied to and thus GFC_TYPE_ARRAY_DATAPTR_TYPE what is "wrong". This type is built in gfc_get_array_type_bounds as /* We define data as an array with the correct size if possible. Much better than doing pointer arithmetic. */ if (stride) rtype = build_range_type (gfc_array_index_type, gfc_index_zero_node, int_const_binop (MINUS_EXPR, stride, build_int_cst (TREE_TYPE (stride), 1))); else rtype = gfc_array_range_type; arraytype = build_array_type (etype, rtype); arraytype = build_pointer_type (arraytype); if (restricted) arraytype = build_qualified_type (arraytype, TYPE_QUAL_RESTRICT); GFC_TYPE_ARRAY_DATAPTR_TYPE (fat_type) = arraytype; The issue might also be the source of "bogus" array bound warnings. Note it might in the end be the issue that the middle-end lacks notion of a stride for array accesses which the Fortran frontend emulates by multiplying the index by the stride. When the stride is negative then the idea to base all arrays on [0:] no longer works out. Note that simply using an unknown TYPE_DOMAIN (aka NULL_TREE) doesn't work either since we still assume that ARRAY_REFs can only have positive indices. Eric - does Ada have something like negative stride array accesses?