[PATCH] gdb/location.c: fix build on gcc-12 (NULL comparison)
Simon Marchi
simon.marchi@polymtl.ca
Mon Nov 15 00:19:31 GMT 2021
The same patch was sent here already, but not merged yet:
https://sourceware.org/pipermail/gdb-patches/2021-November/183279.html
I'll go ahead and merge Pedro's patch, but thanks for sending yours anyway.
Simon
On 2021-11-14 12:31, Sergei Trofimovich via Gdb-patches wrote:
> From: Sergei Trofimovich <siarheit@google.com>
>
> On gcc-12 build fails as:
>
> gdb/location.c: In function 'int event_location_empty_p(const event_location*)':
> 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
> | ^
>
> EL_EXPLICIT returns address to struct field within 'location'.
> It can never be NULL.
> ---
> gdb/location.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/location.c b/gdb/location.c
> index 827294e106a..cda54e14df5 100644
> --- a/gdb/location.c
> +++ b/gdb/location.c
> @@ -960,12 +960,11 @@ event_location_empty_p (const struct event_location *location)
> return 0;
>
> case EXPLICIT_LOCATION:
> - return (EL_EXPLICIT (location) == NULL
> - || (EL_EXPLICIT (location)->source_filename == NULL
> - && EL_EXPLICIT (location)->function_name == NULL
> - && EL_EXPLICIT (location)->label_name == NULL
> - && (EL_EXPLICIT (location)->line_offset.sign
> - == LINE_OFFSET_UNKNOWN)));
> + return (EL_EXPLICIT (location)->source_filename == NULL
> + && EL_EXPLICIT (location)->function_name == NULL
> + && EL_EXPLICIT (location)->label_name == NULL
> + && (EL_EXPLICIT (location)->line_offset.sign
> + == LINE_OFFSET_UNKNOWN));
>
> case PROBE_LOCATION:
> return EL_PROBE (location) == NULL;
>
More information about the Binutils
mailing list