public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/98405] New: missing -Wmaybe-uninitialized passing a member by reference in a ctor initializer list
@ 2020-12-20 22:55 msebor at gcc dot gnu.org
  2020-12-20 22:56 ` [Bug middle-end/98405] " msebor at gcc dot gnu.org
  2022-01-26 17:20 ` msebor at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-12-20 22:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98405
           Summary: missing -Wmaybe-uninitialized passing a member by
                    reference in a ctor initializer list
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

As discussed in
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559258.html, GCC 11
issues -Wmaybe-uninitialized when passing uninitialized variables by reference
to functions that take a const pointer or const reference.  However, it fails
to diagnose the same problem involving members in a C++ constructor.  For
example, in the test case below, only the first instance triggers the warning. 
The other two don't.

$ cat a.C && gcc -O2 -S -Wall a.C

int f (const int*);

struct X {
  int a, b;
};

void g ()
{
  X x;
  x.a = f (&x.b);          // warning (good)
}

struct Y {
 Y ();
 Y (int);
  int a, b;
};

Y::Y (): a (f (&b)) { }    // missing warning
Y::Y (int) { f (&b); }     // missing warning

a.C: In function ‘void g()’:
a.C:10:11: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
   10 |   x.a = f (&x.b);          // warning (good)
      |         ~~^~~~~~
a.C:1:5: note: by argument 1 of type ‘const int*’ to ‘int f(const int*)’
declared here
    1 | int f (const int*);
      |     ^
a.C:9:5: note: ‘x’ declared here
    9 |   X x;
      |     ^

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

* [Bug middle-end/98405] missing -Wmaybe-uninitialized passing a member by reference in a ctor initializer list
  2020-12-20 22:55 [Bug middle-end/98405] New: missing -Wmaybe-uninitialized passing a member by reference in a ctor initializer list msebor at gcc dot gnu.org
@ 2020-12-20 22:56 ` msebor at gcc dot gnu.org
  2022-01-26 17:20 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-12-20 22:56 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |24639
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |diagnostic
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
   Last reconfirmed|                            |2020-12-20
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
I'm testing a fix.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues

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

* [Bug middle-end/98405] missing -Wmaybe-uninitialized passing a member by reference in a ctor initializer list
  2020-12-20 22:55 [Bug middle-end/98405] New: missing -Wmaybe-uninitialized passing a member by reference in a ctor initializer list msebor at gcc dot gnu.org
  2020-12-20 22:56 ` [Bug middle-end/98405] " msebor at gcc dot gnu.org
@ 2022-01-26 17:20 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-01-26 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|msebor at gcc dot gnu.org          |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
I'm not working on this anymore.

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

end of thread, other threads:[~2022-01-26 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-20 22:55 [Bug middle-end/98405] New: missing -Wmaybe-uninitialized passing a member by reference in a ctor initializer list msebor at gcc dot gnu.org
2020-12-20 22:56 ` [Bug middle-end/98405] " msebor at gcc dot gnu.org
2022-01-26 17:20 ` msebor 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).