Silence -Wmaybe-uninitialized warning from target_waitstatus
authorTom Tromey <tromey@adacore.com>
Thu, 7 Apr 2022 16:17:02 +0000 (10:17 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 14 Apr 2022 16:04:13 +0000 (10:04 -0600)
Currently, one use of target_waitstatus yields a warning:

     target/waitstatus.h: In function 'void stop_all_threads()':
     target/waitstatus.h:175:13: warning: 'ws.target_waitstatus::m_value' may be used uninitialized in this function [-Wmaybe-uninitialized]
       175 |     m_value = other.m_value;
   |     ~~~~~~~~^~~~~~~~~~~~~~~

This patch silences the warning.  I tried the "volatile member"
approach that was used for gdb::optional, but that didn't work, so
this patch simply initializes the member.

gdb/target/waitstatus.h

index 7b5faed83c757f7f9a611f3729061a3fed987d3a..63bbd7377499108fa1ba935da0ee21e03cc6fa09 100644 (file)
@@ -418,7 +418,7 @@ private:
       char *execd_pathname;
       /* Syscall number */
       int syscall_number;
-    } m_value;
+    } m_value {};
 };
 
 /* Extended reasons that can explain why a target/thread stopped for a