From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9410D386101C; Mon, 17 Aug 2020 14:40:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9410D386101C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597675218; bh=TwPROQidHlPAaINZkGCLyfCGhgmTGjvuTpD0ZTBdAS4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=j9pazeAZbMXFz8X0lGN+t7rrJ8OXlQmV70wk5KIJjy0Sh63C7DjrT8lNgsjVKZLpw H6VwIRYg7tt+oirZMJulIElnFpGXj/LjInCqnwr24wEQF8X6pg/msjgphbPdAqDHGr UkneQteD3C9tvJA8NLv682ELzIfvTOJOKiJ7DG30= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96645] [9/10/11 Regression] std::variant default constructor Date: Mon, 17 Aug 2020 14:40:18 +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: 9.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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 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 14:40:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96645 --- Comment #4 from Jonathan Wakely --- And libc++'s std::variant is still affected by the same issue, but instead = of the default constructor being deleted it just has the wrong exception specification: #include void testVarStruct() { struct DataWithStruct { struct A { int number =3D 5; // compiles, if remove initialization }; using Member =3D std::variant; Member data; static_assert(std::is_nothrow_default_constructible_v); }; } The difference is that GCC defines the std::variant default constructor as defaulted, but libc++ defines it as: constexpr variant() noexcept(is_nothrow_default_constructible_v) That means the constructor isn't deleted for libc++, it just has the wrong noexcept-specifier. It looks like the nested class DataWithStruct::A isn't considered complete until after DataWithStruct is complete, but I'm not sure why that is.=