--- ./gdb/valarith.c 2016-08-16 15:36:10.680313175 +0200 +++ ./gdb/valarith.c 2016-08-16 15:33:18.696930843 +0200 @@ -193,9 +193,22 @@ value_subscripted_rvalue (struct value * struct type *array_type = check_typedef (value_type (array)); struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); ULONGEST elt_size = type_length_units (elt_type); - ULONGEST elt_offs = elt_size * (index - lowerbound); + ULONGEST elt_offs = index - lowerbound; + LONGEST elt_stride = TYPE_FIELD_BITSIZE (array_type, 0); struct value *v; +if (elt_stride) fprintf(stderr,"value_subscripted_rvalue: elt_stride=%ld\n",elt_stride); + if (elt_stride > 0) + elt_offs *= elt_stride; + else if (elt_stride < 0) + { + int offs = (elt_offs + 1) * elt_stride; + + elt_offs = TYPE_LENGTH (array_type) + offs; + } + else + elt_offs *= elt_size; + if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type) && elt_offs >= type_length_units (array_type))) { --- ./gdb/valops.c 2016-08-16 15:36:10.694313288 +0200 +++ ./gdb/valops.c 2016-08-16 15:04:54.963343948 +0200 @@ -3826,7 +3826,7 @@ value_slice_1 (struct value *array, int struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); unsigned int elt_size, elt_offs; /* ATTRIBUTE_UNUSED: VLA bug: https://sourceware.org/ml/gdb-patches/2016-08/msg00099.html */ - LONGEST elt_stride ATTRIBUTE_UNUSED, ary_high_bound, ary_low_bound; + LONGEST elt_stride, ary_high_bound, ary_low_bound; struct value *v; int slice_range_size, i = 0, row_count = 1, elem_count = 1; @@ -3863,7 +3863,17 @@ value_slice_1 (struct value *array, int elt_offs = lowbound - ary_low_bound; elt_stride = TYPE_LENGTH (TYPE_INDEX_TYPE (array_type)); - elt_offs *= elt_size; +fprintf(stderr,"elt_stride=%d\n",elt_stride); + if (elt_stride > 0) + elt_offs *= elt_stride; + else if (elt_stride < 0) + { + int offs = (elt_offs + 1) * elt_stride; + + elt_offs = TYPE_LENGTH (array_type) + offs; + } + else + elt_offs *= elt_size; /* Check for valid user input. In case of Fortran this was already done in the calling function. */