From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id E01713858006; Tue, 19 Oct 2021 14:01:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E01713858006 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-4508] libstdc++: Change std::variant union member to empty struct X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: c4ecb11e4f7ea15f636e463248c8b14083bef05d X-Git-Newrev: 5a8832b1659e311437d25b7ec8b078be27ae54b8 Message-Id: <20211019140157.E01713858006@sourceware.org> Date: Tue, 19 Oct 2021 14:01:57 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2021 14:01:58 -0000 https://gcc.gnu.org/g:5a8832b1659e311437d25b7ec8b078be27ae54b8 commit r12-4508-g5a8832b1659e311437d25b7ec8b078be27ae54b8 Author: Jonathan Wakely Date: Tue Oct 19 11:53:27 2021 +0100 libstdc++: Change std::variant union member to empty struct This more clearly expresses the intent (a completely unused, trivial type) than using char. It's also consistent with the unions in std::optional. libstdc++-v3/ChangeLog: * include/std/variant (_Uninitialized): Use an empty struct for the unused union member, instead of char. Diff: --- libstdc++-v3/include/std/variant | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index d18365fde22..3da7dad1e82 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -293,8 +293,10 @@ namespace __variant constexpr _Type&& _M_get() && noexcept { return std::move(_M_storage); } + struct _Empty_byte { }; + union { - char _M_nope; + _Empty_byte _M_empty; _Type _M_storage; }; #else