From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CADB03857804; Wed, 7 Apr 2021 19:42:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CADB03857804 From: "msebor at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 9.2.1 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WONTFIX X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: resolution bug_status cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 19:42:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D92722 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |WONTFIX Status|NEW |RESOLVED CC| |msebor at gcc dot gnu.org --- Comment #4 from Martin Sebor --- 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 war= ning does have suppression logic for empty types, including lambdas, but the test case copies the representation bytes of the object directly and there's not= hing to avoid the warning then. So I don't think there's anything for us to do here. In static member function =E2=80=98static void noncopyable_function::trivial_direct_move(noncopyable_function*, noncopyable_function*) [with int N =3D 1]=E2=80=99, inlined from =E2=80=98noncopyable_function::noncopyable_function(noncopyable_function&&)= =E2=80=99 at pr92722.C:32:31, inlined from =E2=80=98int main()=E2=80=99 at pr92722.C:43:40: pr92722.C:22:43: warning: =E2=80=98a.noncopyable_function::direct[0]=E2=80= =99 is used uninitialized [-Wuninitialized] 22 | to->direct[i] =3D from->direct[i]; | ~~~~~~~~~~~~~~^ pr92722.C: In function =E2=80=98int main()=E2=80=99: pr92722.C:42:26: note: =E2=80=98a=E2=80=99 declared here 42 | noncopyable_function a([] {}); | ^ int main () { struct noncopyable_function b; struct noncopyable_function a; char _2; [local count: 1073741824]: # .MEM_7 =3D VDEF <.MEM_1(D)> a =3D{v} {CLOBBER}; # .MEM_8 =3D VDEF <.MEM_7> b =3D{v} {CLOBBER}; # VUSE <.MEM_8> _2 =3D a.direct[0]; <<< a.direct[0] is uninitialized # .MEM_9 =3D VDEF <.MEM_8> b.direct[0] =3D _2; <<< -Wuninitialized # .MEM_3 =3D VDEF <.MEM_9> noncopyable_function::~noncopyable_function (&b); # .MEM_4 =3D VDEF <.MEM_3> noncopyable_function::~noncopyable_function (&a); # .MEM_5 =3D VDEF <.MEM_4> a =3D{v} {CLOBBER}; # .MEM_6 =3D VDEF <.MEM_5> b =3D{v} {CLOBBER}; # VUSE <.MEM_6> return 0; }=