public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/92722] gcc considers "padding" byte of empty lambda to be uninitialized
Date: Wed, 07 Apr 2021 19:42:25 +0000	[thread overview]
Message-ID: <bug-92722-4-ZPEaN0PzBO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-92722-4@http.gcc.gnu.org/bugzilla/>

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;

}

           reply	other threads:[~2021-04-07 19:42 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <bug-92722-4@http.gcc.gnu.org/bugzilla/>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-92722-4-ZPEaN0PzBO@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).