From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C50443858C5E; Thu, 12 Oct 2023 05:17:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C50443858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697087833; bh=6A493nLHO0vyXW4j/MeJKFTvjLVVd/d7pOi+17V22vo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=G7pqSHqf2bzfWiWO8rzI11m3HzvBvKXleadjJ3/UaGbjkr+RR9pkipDkuyh1T5UPX vWKjw/l2kgKe8HqJqD9G4OSi5SEqFSo97/o/Mdj96P+R1hGGY6KnSqKFh+JNcqPwQ3 pjIhdDB//kNEpdF2aIDoBCxWYq9GnU1oyGV4i9IM= From: "iamsupermouse at mail dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111771] Incorrect "is used uninitialized" warning, as if zero-initialization didn't propagate through user-provided default constructors Date: Thu, 12 Oct 2023 05:17:13 +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: 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111771 --- Comment #2 from Egor --- Before calling A's constructor, it will zero `x` anyway. I was also surprised when I learned this yesterday, but it's what the stand= ard says. 1. `()` performs value-initialization on B: http://eel.is/c++draft/dcl.dcl#dcl.init.general-16.4 2. Since B's ctor is not user-provided, that resolves to zero-initialization followed by default-initialization: http://eel.is/c++draft/dcl.dcl#dcl.init.general-9.1.2 3. Zero-initialization of B propagates to A, then propagates to `x` and zer= oes it, regardless of A having a user-provided constructor or not: http://eel.is/c++draft/dcl.dcl#dcl.init.general-6.2 4. Lastly default-initialization of B calls B's constructor and in turn cal= ls A's constructor.=