mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-22 02:50:08 +08:00
gdb/gdbtypes.h: Fix comparison of uninitialized values
When called with an array type of unknown dimensions, is_scalar_type_recursive ended up comparing uninitialized values. This was picked up by the following compiler warning: CXX gdbtypes.o /binutils-gdb/gdb/gdbtypes.c: In function int is_scalar_type_recursive(type*): /binutils-gdb/gdb/gdbtypes.c:3670:38: warning: high_bound may be used uninitialized in this function [-Wmaybe-uninitialized] 3670 | return high_bound == low_bound && is_scalar_type_recursive (elt_type); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /binutils-gdb/gdb/gdbtypes.c:3670:38: warning: low_bound may be used uninitialized in this function [-Wmaybe-uninitialized] This patch makes sure that when dealing with an array of unknown size (or an array of more than 1 element), is_scalar_type_recursive returns false. gdb/ChangeLog: * gdbtypes.c (is_scalar_type_recursive): Prevent comparison between uninitialized values. Change-Id: Ifc005ced166aa7a065fef3e652977bae67625bf4
This commit is contained in:

committed by
Simon Marchi

parent
99d8bab0c1
commit
f867677682
@ -1,3 +1,8 @@
|
|||||||
|
2020-12-24 Lancelot SIX <lsix@lancelotsix.com>
|
||||||
|
|
||||||
|
* gdbtypes.c (is_scalar_type_recursive): Prevent comparison
|
||||||
|
between uninitialized values.
|
||||||
|
|
||||||
2020-12-23 Andrew Burgess <andrew.burgess@embecosm.com>
|
2020-12-23 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* expprint.c (print_subexp_standard): Replace uses of
|
* expprint.c (print_subexp_standard): Replace uses of
|
||||||
|
@ -3665,9 +3665,11 @@ is_scalar_type_recursive (struct type *t)
|
|||||||
LONGEST low_bound, high_bound;
|
LONGEST low_bound, high_bound;
|
||||||
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (t));
|
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (t));
|
||||||
|
|
||||||
get_discrete_bounds (t->index_type (), &low_bound, &high_bound);
|
if (get_discrete_bounds (t->index_type (), &low_bound, &high_bound))
|
||||||
|
return (high_bound == low_bound
|
||||||
return high_bound == low_bound && is_scalar_type_recursive (elt_type);
|
&& is_scalar_type_recursive (elt_type));
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/* Are we dealing with a struct with one element? */
|
/* Are we dealing with a struct with one element? */
|
||||||
else if (t->code () == TYPE_CODE_STRUCT && t->num_fields () == 1)
|
else if (t->code () == TYPE_CODE_STRUCT && t->num_fields () == 1)
|
||||||
|
Reference in New Issue
Block a user