From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 489EE3858C27; Thu, 1 Apr 2021 00:38:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 489EE3858C27 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/78391] g++ (any version) at O0 (for O1, O2, O3 is ok) doesn't warn when class members are used uninitialized. Date: Thu, 01 Apr 2021 00:38:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 7.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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: cf_known_to_fail cc cf_reconfirmed_on 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: Thu, 01 Apr 2021 00:38:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D78391 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail| |10.2.0, 11.0, 7.3.0, 8.3.0, | |9.2.0 CC| |msebor at gcc dot gnu.org Last reconfirmed|2016-11-17 00:00:00 |2021-3-31 --- Comment #4 from Martin Sebor --- Reconfirmed with GCC 11. GCC does issue -Wuninitialized without optimization on an equivalent test c= ase with an explicit ctor. The difference between the two ctors is that B's ha= s a clobber: $ cat pr78391.C && PRED_DUMP=3Deuninit gcc -S -Wall pr78391.C struct A { int x =3D w; int w =3D 10; }; int f () { A a; return a.x; } struct B { int x, w; B (): x(w), w (10) { } }; int g () { B b; return b.x; } void A::A (struct A * const this) { int _1; : # VUSE <.MEM_2(D)> <<< no clobber _1 =3D this_3(D)->w; <<< -Wuninitialized # .MEM_4 =3D VDEF <.MEM_2(D)> this_3(D)->x =3D _1; # .MEM_5 =3D VDEF <.MEM_4> this_3(D)->w =3D 10; # VUSE <.MEM_5> return; } int f () { struct A a; int D.2439; int _3; : # .MEM_2 =3D VDEF <.MEM_1(D)> A::A (&a); # VUSE <.MEM_2> _3 =3D a.x; # .MEM_4 =3D VDEF <.MEM_2> a =3D{v} {CLOBBER}; : : # VUSE <.MEM_4> return _3; } void B::B (struct B * const this) { int _1; : # .MEM_4 =3D VDEF <.MEM_2(D)> *this_3(D) =3D{v} {CLOBBER}; <<< clobber here # VUSE <.MEM_4> _1 =3D this_3(D)->w; <<< -Wuninitialized # .MEM_5 =3D VDEF <.MEM_4> this_3(D)->x =3D _1; # .MEM_6 =3D VDEF <.MEM_5> this_3(D)->w =3D 10; # VUSE <.MEM_6> return; } pr78391.C: In constructor =E2=80=98B::B()=E2=80=99: pr78391.C:9:30: warning: =E2=80=98*this.B::w=E2=80=99 is used uninitialized= [-Wuninitialized] 9 | struct B { int x, w; B (): x(w), w (10) { } }; | ^ int g () { struct B b; int D.2442; int _3; : # .MEM_2 =3D VDEF <.MEM_1(D)> B::B (&b); # VUSE <.MEM_2> _3 =3D b.x; # .MEM_4 =3D VDEF <.MEM_2> b =3D{v} {CLOBBER}; : : # VUSE <.MEM_4> return _3; }=