2010-12-13 Ken Werner * valops.c (value_one): Use get_array_bounds to compute the number of array elements instead of dividing the length of the array by the length of the element types. * valarith.c (value_complement, value_neg): Likewise. Index: gdb/valarith.c =================================================================== RCS file: /cvs/src/src/gdb/valarith.c,v retrieving revision 1.91 diff -u -r1.91 valarith.c --- gdb/valarith.c 29 Nov 2010 21:18:16 -0000 1.91 +++ gdb/valarith.c 13 Dec 2010 19:43:52 -0000 @@ -1766,9 +1766,13 @@ { struct value *tmp, *val = allocate_value (type); struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type)); - int i, n = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; - for (i = 0; i < n; i++) + if (!get_array_bounds (type, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); + + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_neg (value_subscript (arg1, i)); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), @@ -1798,10 +1802,14 @@ { struct value *tmp; struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type)); - int i, n = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; + + if (!get_array_bounds (type, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); val = allocate_value (type); - for (i = 0; i < n; i++) + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_complement (value_subscript (arg1, i)); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), Index: gdb/valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.259 diff -u -r1.259 valops.c --- gdb/valops.c 1 Dec 2010 16:49:41 -0000 1.259 +++ gdb/valops.c 13 Dec 2010 19:43:52 -0000 @@ -877,11 +877,15 @@ else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1)) { struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type1)); - int i, n = TYPE_LENGTH (type1) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; struct value *tmp; + if (!get_array_bounds (type1, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); + val = allocate_value (type); - for (i = 0; i < n; i++) + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_one (eltype, lv); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype),