[PATCH 1/2] Fix the unitialized bit in a struct field corresponding to enumb

Luis Machado lgustavo@codesourcery.com
Wed Feb 15 14:07:00 GMT 2017


On 02/11/2017 09:23 AM, Maxim Akhmedov wrote:
> Without setting this bit, even for a small enumeration types their member fields contain random 0/1's as the values of "artificial". When comparing two instances of exactly the same
> enum type, the result depends on whether their members contain the same garbage as the value of artificial.
>
> gdb/ChangeLog:
> 2017-02-11  Maxim Akhmedov  <max42@yandex-team.ru>
>
> 	* dwarf2read.c: fix uninitialized bit in a struct field corresponding
> 	to enumeration member.
>
> ---
>  gdb/dwarf2read.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 774ed73075..676da14c58 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -13652,6 +13652,7 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
>                   FIELD_TYPE (fields[num_fields]) = NULL;
>                   SET_FIELD_ENUMVAL (fields[num_fields], SYMBOL_VALUE (sym));
>                   FIELD_BITSIZE (fields[num_fields]) = 0;
> +                 FIELD_ARTIFICIAL (fields[num_fields]) = 0;
>
>                   num_fields++;
>                 }

This looks OK to me, though it would've been nice to zero out the entire 
field struct and not just individual bits of it.

There are basically two ways we're doing this:

- XNEW and then memset to 0.
- XCNEW, which already handles zeroing things out.



More information about the Gdb-patches mailing list