public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/92722] gcc considers "padding" byte of empty lambda to be uninitialized
       [not found] <bug-92722-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-07 19:42 ` msebor at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: msebor at gcc dot gnu.org @ 2021-04-07 19:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|NEW                         |RESOLVED
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
The IL the warning works with is below.  It shows an unconditional read of the
uninitialized member array bytes so the warning behaves correctly.  The warning
does have suppression logic for empty types, including lambdas, but the test
case copies the representation bytes of the object directly and there's nothing
to avoid the warning then.  So I don't think there's anything for us to do
here.

In static member function ‘static void
noncopyable_function::trivial_direct_move(noncopyable_function*,
noncopyable_function*) [with int N = 1]’,
    inlined from
‘noncopyable_function::noncopyable_function(noncopyable_function&&)’ at
pr92722.C:32:31,
    inlined from ‘int main()’ at pr92722.C:43:40:
pr92722.C:22:43: warning: ‘a.noncopyable_function::direct[0]’ is used
uninitialized [-Wuninitialized]
   22 |             to->direct[i] = from->direct[i];
      |                             ~~~~~~~~~~~~~~^
pr92722.C: In function ‘int main()’:
pr92722.C:42:26: note: ‘a’ declared here
   42 |     noncopyable_function a([] {});
      |                          ^
int main ()
{
  struct noncopyable_function b;
  struct noncopyable_function a;
  char _2;

  <bb 2> [local count: 1073741824]:
  # .MEM_7 = VDEF <.MEM_1(D)>
  a ={v} {CLOBBER};
  # .MEM_8 = VDEF <.MEM_7>
  b ={v} {CLOBBER};
  # VUSE <.MEM_8>
  _2 = a.direct[0];           <<< a.direct[0] is uninitialized
  # .MEM_9 = VDEF <.MEM_8>
  b.direct[0] = _2;           <<< -Wuninitialized
  # .MEM_3 = VDEF <.MEM_9>
  noncopyable_function::~noncopyable_function (&b);
  # .MEM_4 = VDEF <.MEM_3>
  noncopyable_function::~noncopyable_function (&a);
  # .MEM_5 = VDEF <.MEM_4>
  a ={v} {CLOBBER};
  # .MEM_6 = VDEF <.MEM_5>
  b ={v} {CLOBBER};
  # VUSE <.MEM_6>
  return 0;

}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-07 19:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-92722-4@http.gcc.gnu.org/bugzilla/>
2021-04-07 19:42 ` [Bug c++/92722] gcc considers "padding" byte of empty lambda to be uninitialized 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).