[PATCH] gdb/location.c: fix build on gcc-12 (NULL comparison)
Sergei Trofimovich
slyfox@gentoo.org
Sun Nov 14 17:31:12 GMT 2021
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;
--
2.33.1
More information about the Binutils
mailing list