Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [committed][gdb/tui] Fix Wmaybe-uninitialized warning in tui-winsource.c
Date: Thu, 23 Jul 2020 13:46:26 +0200	[thread overview]
Message-ID: <20200723114624.GA26119@delia> (raw)

Hi,

When compiling with CFLAGS/CXXFLAGS="-O0 -g -Wall" and using g++ 11.0.0, we
run into:
...
src/gdb/tui/tui-winsource.c: In function \
  'void tui_update_all_breakpoint_info(breakpoint*)':
src/gdb/tui/tui-winsource.c:427:58: warning: '<unknown>' may be used \
  uninitialized [-Wmaybe-uninitialized]
  427 |   for (tui_source_window_base *win : tui_source_windows ())
      |                                                          ^
In file included from src/gdb/tui/tui-winsource.c:38:
src/gdb/tui/tui-winsource.h:236:30: note: by argument 1 of type \
  'const tui_source_windows*' to 'tui_source_window_iterator \
  tui_source_windows::begin() const' declared here
  236 |   tui_source_window_iterator begin () const
      |                              ^~~~~
src/gdb/tui/tui-winsource.c:427:58: note: '<anonymous>' declared here
  427 |   for (tui_source_window_base *win : tui_source_windows ())
      |                                                          ^
...

The warning doesn't make sense for an empty struct, PR gcc/96295 has been
filed about that.

For now, work around the warning by defining a default constructor.

Build on x86_64-linux.

Committed to trunk.

Thanks,
- Tom

[gdb/tui] Fix Wmaybe-uninitialized warning in tui-winsource.c

gdb/ChangeLog:

2020-07-23  Tom de Vries  <tdevries@suse.de>

	PR tui/26282
	* tui/tui-winsource.h (struct tui_source_windows::tui_source_windows):
	New default constructor.

---
 gdb/tui/tui-winsource.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index fab1487f63..ba9c0fd505 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -233,6 +233,11 @@ struct tui_source_window_iterator
 
 struct tui_source_windows
 {
+  /* Work around Wmaybe-uninitalized warning with g++ 11.0.0, see also
+     PR gcc/96295.  Note that "tui_source_windows () = default" doesn't work
+     around the warning.  */
+  tui_source_windows () {}
+
   tui_source_window_iterator begin () const
   {
     return tui_source_window_iterator (tui_windows.begin (),


                 reply	other threads:[~2020-07-23 11:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200723114624.GA26119@delia \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox