From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 88FD63858CDA; Wed, 11 Oct 2023 14:42:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88FD63858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697035324; bh=8C3pMnWcZrlM+kn9hZd/G4/RFQxDSWSrlqN6GzDHYJY=; h=From:To:Subject:Date:From; b=d3gx6lEbKQ+atDtnbQNM3wPtIkyKJtZnTwC6LNoM38ZgFrvJ8zk9bNgdoxHYao5N/ E6Q6G8hN0pBEaLpNaZav+7w9K+r9D2V0k192KTL+pyXskliCN+jThk4jhVWGwJC6wv +fD0lNAZ6cLE+82Np8k2r4EfSkEQAuHhr21mwJhA= From: "iamsupermouse at mail dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111771] New: Incorrect "is used uninitialized" warning, as if zero-initialization didn't propagate through user-provided default constructors Date: Wed, 11 Oct 2023 14:42:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: iamsupermouse at mail dot ru X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111771 Bug ID: 111771 Summary: Incorrect "is used uninitialized" warning, as if zero-initialization didn't propagate through user-provided default constructors Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iamsupermouse at mail dot ru Target Milestone: --- Here's the code. GCC with `-Wall -O3` warns that `x` is used uninitialized, even though it's zeroed. struct A { A() {} int x; }; struct B : A {}; int main() { B b =3D B(); return b.x; } Since `B` doesn't have a user-provided default constructor, value-initializ= ing it like this performs zero-initialization, which propagates recursively (http://eel.is/c++draft/dcl.dcl#dcl.init.general-6.2) over all members, zer= oing everything. Yet GCC incorrectly warns about `x` being uninitialized.=