public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug tui/26282] New: [tui, Wmaybe-initialized] Warning in tui-winsource.c
@ 2020-07-22 14:17 vries at gcc dot gnu.org
  2020-07-22 15:25 ` [Bug tui/26282] " vries at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-07-22 14:17 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26282

            Bug ID: 26282
           Summary: [tui, Wmaybe-initialized] Warning in tui-winsource.c
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: tui
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

With -Wall, -O0 and g++-11:
...
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 ())
      |                                                          ^
...

Tentative patch:
...
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index fab1487f63..c8cacc019b 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -233,6 +233,8 @@ struct tui_source_window_iterator

 struct tui_source_windows
 {
+  tui_source_windows () {}
+
   tui_source_window_iterator begin () const
   {
     return tui_source_window_iterator (tui_windows.begin (),
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tui/26282] [tui, Wmaybe-initialized] Warning in tui-winsource.c
  2020-07-22 14:17 [Bug tui/26282] New: [tui, Wmaybe-initialized] Warning in tui-winsource.c vries at gcc dot gnu.org
@ 2020-07-22 15:25 ` vries at gcc dot gnu.org
  2020-07-22 15:54 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-07-22 15:25 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26282

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tui/26282] [tui, Wmaybe-initialized] Warning in tui-winsource.c
  2020-07-22 14:17 [Bug tui/26282] New: [tui, Wmaybe-initialized] Warning in tui-winsource.c vries at gcc dot gnu.org
  2020-07-22 15:25 ` [Bug tui/26282] " vries at gcc dot gnu.org
@ 2020-07-22 15:54 ` tromey at sourceware dot org
  2020-07-23  7:56 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at sourceware dot org @ 2020-07-22 15:54 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26282

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
I don't understand why this patch is needed, or why this
error occurs.  I guess it's a compiler bug -- tui_source_windows
is empty, so it doesn't mean anything for it to be
uninitialized.

I suggest filing a compiler bug for this.
A workaround patch is fine, but I think it could use a comment
explaining why it's needed.
Also I guess I'd try "= default" rather than "{}".

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tui/26282] [tui, Wmaybe-initialized] Warning in tui-winsource.c
  2020-07-22 14:17 [Bug tui/26282] New: [tui, Wmaybe-initialized] Warning in tui-winsource.c vries at gcc dot gnu.org
  2020-07-22 15:25 ` [Bug tui/26282] " vries at gcc dot gnu.org
  2020-07-22 15:54 ` tromey at sourceware dot org
@ 2020-07-23  7:56 ` vries at gcc dot gnu.org
  2020-07-23  9:49 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-07-23  7:56 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26282

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #1)
> I don't understand why this patch is needed, or why this
> error occurs.  I guess it's a compiler bug -- tui_source_windows
> is empty, so it doesn't mean anything for it to be
> uninitialized.
> 
> I suggest filing a compiler bug for this.

Done: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96295

> A workaround patch is fine, but I think it could use a comment
> explaining why it's needed.
> Also I guess I'd try "= default" rather than "{}".

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tui/26282] [tui, Wmaybe-initialized] Warning in tui-winsource.c
  2020-07-22 14:17 [Bug tui/26282] New: [tui, Wmaybe-initialized] Warning in tui-winsource.c vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-07-23  7:56 ` vries at gcc dot gnu.org
@ 2020-07-23  9:49 ` vries at gcc dot gnu.org
  2020-07-23 11:45 ` cvs-commit at gcc dot gnu.org
  2020-07-23 11:47 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-07-23  9:49 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26282

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #1)
> Also I guess I'd try "= default" rather than "{}".

FTR, I've tried that as well, but that didn't work.

The workaround works based on the presence of a constructor call, and for this:
...
class A {
 public:
  A () {}
};

void
foo (void)
{
  A a;
}
...
we have a constructor (showing gimple here):
...
foo ()
{
  struct A a;

  try
    {
      A::A (&a);
    }
  finally
    {
      a = {CLOBBER};
    }
}
...
but for this:
...
class A {
 public:
  A () = default;
};

void
foo (void)
{
  A a;
}
...
the compiler AFAIU decides that the default constructor is empty and therefore
doesn't need to be called:
...
foo ()
{
  struct A a;

  try
    {

    }
  finally
    {
      a = {CLOBBER};
    }
}
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tui/26282] [tui, Wmaybe-initialized] Warning in tui-winsource.c
  2020-07-22 14:17 [Bug tui/26282] New: [tui, Wmaybe-initialized] Warning in tui-winsource.c vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-07-23  9:49 ` vries at gcc dot gnu.org
@ 2020-07-23 11:45 ` cvs-commit at gcc dot gnu.org
  2020-07-23 11:47 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-23 11:45 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26282

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=90fcc46681979a7759d16e738a98c9e666e6e88f

commit 90fcc46681979a7759d16e738a98c9e666e6e88f
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Jul 23 13:45:46 2020 +0200

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

    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.

    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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tui/26282] [tui, Wmaybe-initialized] Warning in tui-winsource.c
  2020-07-22 14:17 [Bug tui/26282] New: [tui, Wmaybe-initialized] Warning in tui-winsource.c vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-07-23 11:45 ` cvs-commit at gcc dot gnu.org
@ 2020-07-23 11:47 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-07-23 11:47 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26282

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.1
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch working around warning committed, marking resolved-fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-23 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 14:17 [Bug tui/26282] New: [tui, Wmaybe-initialized] Warning in tui-winsource.c vries at gcc dot gnu.org
2020-07-22 15:25 ` [Bug tui/26282] " vries at gcc dot gnu.org
2020-07-22 15:54 ` tromey at sourceware dot org
2020-07-23  7:56 ` vries at gcc dot gnu.org
2020-07-23  9:49 ` vries at gcc dot gnu.org
2020-07-23 11:45 ` cvs-commit at gcc dot gnu.org
2020-07-23 11:47 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).