mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
vla: print "variable length" for unresolved dynamic bounds
1| void foo (size_t n) {
2| int vla[n];
3| }
Given the following expression
(gdb) ptype &vla
Gdb evaluates the expression with EVAL_AVOID_SIDE_EFFECTS and thus
does not resolve the bounds information and misinterprets the high
bound as a constant. The current output is:
type = int (*)[1289346]
this patch deals with this case and prints:
type = int (*)[variable length]
instead.
gdb/ChangeLog:
* c-typeprint.c (c_type_print_varspec_suffix): Added
check for not yet resolved high bound. If unresolved, print
"variable length" string to the console instead of random
length.
This commit is contained in:
committed by
Joel Brobecker
parent
9f1f738ada
commit
1d42e4c4d8
@@ -689,7 +689,11 @@ c_type_print_varspec_suffix (struct type *type,
|
||||
|
||||
fprintf_filtered (stream, (is_vector ?
|
||||
" __attribute__ ((vector_size(" : "["));
|
||||
if (get_array_bounds (type, &low_bound, &high_bound))
|
||||
/* Bounds are not yet resolved, print a bounds placeholder instead. */
|
||||
if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR
|
||||
|| TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST)
|
||||
fprintf_filtered (stream, "variable length");
|
||||
else if (get_array_bounds (type, &low_bound, &high_bound))
|
||||
fprintf_filtered (stream, "%s",
|
||||
plongest (high_bound - low_bound + 1));
|
||||
fprintf_filtered (stream, (is_vector ? ")))" : "]"));
|
||||
|
||||
Reference in New Issue
Block a user