The following python command fails:
(gdb) python print gdb.lookup_type('char').array(1, 0)
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: Array length must not be negative
Error while executing Python code.
The above is trying to create an empty array, which is fairly command
in Ada.
gdb/ChangeLog:
* python/py-type.c (typy_array_1): Do not raise negative-length
exception if N2 is equal to N1 - 1.
gdb/testsuite/ChangeLog:
* gdb.python/py-type.exp: Add a couple test about empty
array creation, and negative-length array creation.
+
+ * python/py-type.c (typy_array_1): Do not raise negative-length
+ exception if N2 is equal to N1 - 1.
+
* c-exp.y: Whitespace cleanup.
n1 = 0;
}
- if (n2 < n1)
+ if (n2 < n1 - 1)
{
PyErr_SetString (PyExc_ValueError,
_("Array length must not be negative"));
+
+ * gdb.python/py-type.exp: Add a couple test about empty
+ array creation, and negative-length array creation.
+
* gdb.cp/nsalias.exp: Fix output of external/declaration flags.
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
+gdb_test "python print gdb.lookup_type('char').array(1, 0)" \
+ "char \\\[0\\\]"
+
+gdb_test "python print gdb.lookup_type('char').array(1, -1)" \
+ "Array length must not be negative.*"
+
with_test_prefix "lang_c" {
runto_bp "break to inspect struct and array."
test_fields "c"