[Bug middle-end/95848] missing -Wuninitialized passing structs by value (VOPS)

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 12 17:15:31 GMT 2021


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
      Known to fail|                            |10.2.0, 11.0, 9.3.0
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-01-12

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
No improvement in GCC 11, even though passing structs by reference to const
pointer/reference arguments is diagnosed:

$ cat a.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout a.c
struct S { int i; };

void f (const struct S*);
void g (struct S);

void ff (void)
{
  struct S s;
  f (&s);    // -Wmaybe-uninitialized (good)
}

void gg (void)
{
  struct S s;
  g (s);     // missing warning
}

a.c: In function ‘ff’:
a.c:9:3: warning: ‘s’ may be used uninitialized [-Wmaybe-uninitialized]
    9 |   f (&s);    // -Wmaybe-uninitialized (good)
      |   ^~~~~~
a.c:3:6: note: by argument 1 of type ‘const struct S *’ to ‘f’ declared here
    3 | void f (const struct S*);
      |      ^
a.c:8:12: note: ‘s’ declared here
    8 |   struct S s;
      |            ^

;; Function ff (ff, funcdef_no=0, decl_uid=1949, cgraph_uid=1, symbol_order=0)

void ff ()
{
  struct S s;

  <bb 2> [local count: 1073741824]:
  f (&s);
  s ={v} {CLOBBER};
  return;

}



;; Function gg (gg, funcdef_no=1, decl_uid=1953, cgraph_uid=2, symbol_order=1)

void gg ()
{
  struct S s;

  <bb 2> [local count: 1073741824]:
  g (s); [tail call]
  s ={v} {CLOBBER};
  return;

}


More information about the Gcc-bugs mailing list