From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3683E3857008; Thu, 20 Apr 2023 19:32:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3683E3857008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682019123; bh=Qfbfza9QSzWbT7HeI0MOMH9DzAeFJKNl45LAbjAu9Hw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dBbc4BdR76LhVKdH4Qa0NeYW42EpKKh3yEezgXXCF3B9pw/PaQNIEQmIk2QfT7Bml XKvUjiAWuporPD0zaLuhhg7wGDAY7hBYFQhZJNJJQlvotF9cN6IMXGtknJoQm1AmDv 6zXJVmieSjgWqY0sWS2T57yHwwo+TtOrS1dCrhFg= From: "panigstein at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108993] Value initialization does not occur for derived class , for gcc versions > 5 Date: Thu, 20 Apr 2023 19:32:03 +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: 12.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: panigstein at hotmail dot com 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=3D108993 --- Comment #7 from Pablo Anigstein --- (In reply to Jonathan Wakely from comment #5) > (In reply to Jonathan Wakely from comment #3) > > (In reply to Pablo Anigstein from comment #2) > > > (In reply to Andrew Pinski from comment #1) > > > > Hmm, > > > > I noticed that since GCC 7 with -std=3Dc++17, the b.x is not initi= alized at > > > > all. So the question I have is there a difference between C++ stand= ards here? > >=20 > > Derived is an aggregate in C++17, so b{} does aggregate init, not value= init. >=20 > And that means its Base subobject is copy-initialized from {} which means= we > get a value-initialized object, so it's correct that b.x is not initializ= ed > in C++17 (which is what is shown in your godbolt link, because you didn't > specify any -std option to override the -std=3Dgnu++17 default). >=20 > With -std=3Dc++14 it looks like b.x is always set to zero, if I'm reading= the > assembly output correctly (but I'm probably not). Here is an updated example: https://godbolt.org/z/YePjhxKE4. Note that now Derived is not an aggregate for any standard version due to the private mem= ber. Still zero-initialization does not happen for the Base sub-object for the c= ase where Base has a user-provided default constructor when compiling with -O1 = and above.=