[PATCH] Fix unitialized warning on gdb/typeprint.c:whatis_exp

Sergio Durigan Junior sergiodj@redhat.com
Tue Jan 16 20:32:00 GMT 2018


This simple patch initializes "struct value *val" to NULL, which
silences a when compiling GDB with certain GCC versions.

This warning is technically incorrect, because there is now way that
"val" will be used unitialized if you look at the code flow, but it's
a simple "fix" and doesn't do any harm.

Is it OK to push this to master and 8.1?  I believe I will still need
to create a bug with the 8.1 milestone set, even for this simple
patch.

gdb/ChangeLog:
2017-01-16  Sergio Durigan Junior  <sergiodj@redhat.com>

	* typeprint.c (whatis_exp): Initialize "val" to NULL.
---
 gdb/typeprint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 9a125076a1..bf9aec5436 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -405,7 +405,7 @@ error_unknown_type (const char *sym_print_name)
 static void
 whatis_exp (const char *exp, int show)
 {
-  struct value *val;
+  struct value *val = NULL;
   struct cleanup *old_chain;
   struct type *real_type = NULL;
   struct type *type;
-- 
2.14.3



More information about the Gdb-patches mailing list