From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 495DA3858C35; Sun, 3 Dec 2023 20:54:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 495DA3858C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701636886; bh=AomGokalGxkI8UMGeXaJzlnRCJbr1HTTD0zqkn1M7W8=; h=From:To:Subject:Date:From; b=c5YigDdr8S7dbFUtGY6yprTCIezEenaELtLHl8JR4ldAJ5Hsa3d7RYoqoyiLC3G8+ mH4m6adDXF4uAQcsQXXKn2Bq+fAy2pr3ieBh1G57z+LCtLahdKLtZ41BIStwOp4qg0 T62zWKj40TYwB7w7ZUKmp+nAGWGgicgamIWaw0sM= From: "luigighiron at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112839] New: Unable to default initialize member variable in specific circumstances Date: Sun, 03 Dec 2023 20:54:45 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: luigighiron at gmail 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: 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=3D112839 Bug ID: 112839 Summary: Unable to default initialize member variable in specific circumstances Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: luigighiron at gmail dot com Target Milestone: --- The following code is not accepted by GCC: struct A { struct B { int C =3D 0; }; A() =3D default; A(int) {} std::pair p; }; The error message generated indicates that it was unable to find a construc= tor to call in the constructor A(int). Doing any of the following seems to remove the error: 1. Removing the constructor A() 2. Explicitly define the constructor A() 3. Defining a default constructor for B (that isn't defaulted) 4. Removing the default value from C 5. Initializing p when it is being declared, i.e. std::pair p{}; 6. Defining B outside of the class 7. Using a non-default constructor in the member initializer list Clang, MSVC, and old versions of GCC (version 8, version 5, and version 4) accept this code.=