diff mbox series

[committed] libstdc++: Change std::variant union member to empty struct

Message ID YW7P5Pu+xFqq/6o7@redhat.com
State New
Headers show
Series [committed] libstdc++: Change std::variant union member to empty struct | expand

Commit Message

Jonathan Wakely Oct. 19, 2021, 2:02 p.m. UTC
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.

Tested powerpc64le-linux. Committed to trunk.
commit 5a8832b1659e311437d25b7ec8b078be27ae54b8
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 19 11:53:27 2021

    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 mbox series

Patch

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