[PATCH][gdb/build] Fix -Werror=bool-compare warning in update_static_array_size

Tom Tromey tom@tromey.com
Wed Nov 18 16:59:58 GMT 2020


>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> I suppose that this code was written with the return codes of
Tom> get_discrete_bounds in mind, where -1 means "bounds not set".

Tom> So, I think this can be fixed by just dropping the compare:
Tom> ...
Tom> diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
Tom> index cde07702734..b822a369a16 100644
Tom> --- a/gdb/gdbtypes.c
Tom> +++ b/gdb/gdbtypes.c
Tom> @@ -1247,7 +1247,7 @@ update_static_array_size (struct type *type)
Tom>        if (element_type->code () == TYPE_CODE_ARRAY
Tom>           && TYPE_LENGTH (element_type) != 0
Tom>           && TYPE_FIELD_BITSIZE (element_type, 0) != 0
Tom> -         && get_array_bounds (element_type, &low_bound, &high_bound) >= 0
Tom> +         && get_array_bounds (element_type, &low_bound, &high_bound)
Tom>           && high_bound >= low_bound)
Tom>         TYPE_FIELD_BITSIZE (type, 0)
Tom>           = ((high_bound - low_bound + 1)
Tom> ...

Tom> I'll put this through a round of build and test on x86_64-linux.

Tom> Any comments?

Looks good to me.  Sorry about the oversight.

Tom


More information about the Gdb-patches mailing list