From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2E3523857C6D; Mon, 17 Aug 2020 07:58:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E3523857C6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597651089; bh=bR1FXodoY2TCNUtubjEj1pwELrpCxcjS6rmHEG0d0gk=; h=From:To:Subject:Date:From; b=ugTMB/lRUpGuF84V4OVVAl9HEbi8ZH5gCwoS+l4pyUc4HtgpoC4RlLYzx0Hv6LzDk oWwdr2wzYUqxvpiV1eaczKY9wgAUCm29mFaoZw0hWkW8ZnEG04g8QyvhuJTd/JJpmi Sw3uZ2dtP1UZUtHf2/NxXNecmYuwD2x8YE5WM2xM= From: "dev at hrookami dot icu" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/96645] New: std::variant default constructor Date: Mon, 17 Aug 2020 07:58:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dev at hrookami dot icu 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 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: Mon, 17 Aug 2020 07:58:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96645 Bug ID: 96645 Summary: std::variant default constructor Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: dev at hrookami dot icu Target Milestone: --- Appears in version 9 and above. Flags: -std=3Dc++17 Code: #include void testVariant() { struct DataWithVariant { using Member =3D std::variant; Member d; }; auto d =3D DataWithVariant{}; } void testVarStruct() { struct DataWithStruct { struct A { int number =3D 5; // compiles, if remove initialization }; struct B { bool flag =3D false; }; using Member =3D std::variant; Member data; }; auto d =3D DataWithStruct{}; } int main() { testVariant(); testVarStruct(); } Compiler output: : In function 'void testVarStruct()': :26:29: error: use of deleted function 'std::variant<_Types>::varia= nt() [with _Types =3D {testVarStruct()::DataWithStruct::A, testVarStruct()::DataWithStruct::B}]' 26 | auto d =3D DataWithStruct{}; | ^ In file included from :1: /opt/compiler-explorer/gcc-9.1.0/include/c++/9.1.0/variant:1287:7: note: 'std::variant<_Types>::variant() [with _Types =3D {testVarStruct()::DataWithStruct::A, testVarStruct()::DataWithStruct::B}]' = is implicitly deleted because the default definition would be ill-formed: 1287 | variant() =3D default; | ^~~~~~~ /opt/compiler-explorer/gcc-9.1.0/include/c++/9.1.0/variant:1287:7: error: u= se of deleted function 'constexpr std::_Enable_default_constructor::_Enable_default_constructor() [with _Tag =3D std::variant]' In file included from /opt/compiler-explorer/gcc-9.1.0/include/c++/9.1.0/variant:38, from :1: /opt/compiler-explorer/gcc-9.1.0/include/c++/9.1.0/bits/enable_special_memb= ers.h:110:15: note: declared here 110 | constexpr _Enable_default_constructor() noexcept =3D delete; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ It compiles if move nested structs in global namespace or remove initialize= r.=