[PATCH] Fix build with current GCC: EL_EXPLICIT(location) always non-NULL

Simon Marchi simark@simark.ca
Tue Nov 9 18:19:30 GMT 2021


On 2021-11-09 12:33 p.m., Pedro Alves wrote:
> Compiling GDB with current GCC (1b4a63593b) runs into this:
>
>   src/gdb/location.c: In function ‘int event_location_empty_p(const event_location*)’:
>   src/gdb/location.c:963:38: error: the address of ‘event_location::<unnamed union>::explicit_loc’ will never be NULL [-Werror=address]
>     963 |       return (EL_EXPLICIT (location) == NULL
> 	|                                      ^
>   src/gdb/location.c:57:30: note: ‘event_location::<unnamed union>::explicit_loc’ declared here
>      57 |     struct explicit_location explicit_loc;
> 	|                              ^~~~~~~~~~~~
>
> GCC is right, EL_EXPLICIT is defined as returning the address of an
> union field:
>
>       /* An explicit location.  */
>       struct explicit_location explicit_loc;
>   #define EL_EXPLICIT(P) (&((P)->u.explicit_loc))
>
> and thus must always be non-NULL.

Looks good (and relatively obvious) to me.

Simon


More information about the Gdb-patches mailing list