[Bug middle-end/88518] Function call defeats -Wuninitialized

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Apr 6 19:59:29 GMT 2021


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
   Last reconfirmed|                            |2021-4-6
         Resolution|---                         |DUPLICATE
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed as a duplicate of pr60488 (which itself is likely a duplicate of some
older bug).  A variable whose address escapes is not considered by the warning.
 It sees the following IL:

;; Function f (f, funcdef_no=0, decl_uid=1947, cgraph_uid=1, symbol_order=0)

void f ()
{
  long unsigned int i;
  long unsigned int i.0_1;
  long unsigned int _2;

  <bb 2> [local count: 1073741824]:
  # .MEM_4 = VDEF <.MEM_3(D)>
  h ();
  # VUSE <.MEM_4>
  i.0_1 = i;                    <<< i loaded from memory and not considered
  _2 = i.0_1 + 1;               <<< missing -Wuninitialized
  # .MEM_5 = VDEF <.MEM_4>
  i = _2;
  # .MEM_6 = VDEF <.MEM_5>
  g (&i);
  # .MEM_7 = VDEF <.MEM_6>
  i ={v} {CLOBBER};
  # VUSE <.MEM_7>
  return;

}

The pointless load persists until the assembly:

f:
.LFB0:
        .cfi_startproc
        subq    $24, %rsp
        .cfi_def_cfa_offset 32
        call    h
        leaq    8(%rsp), %rdi   <<< i loaded from memory
        addq    $1, 8(%rsp)     <<< i++
        call    g
        addq    $24, %rsp
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc

*** This bug has been marked as a duplicate of bug 60488 ***


More information about the Gcc-bugs mailing list