]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Change std::variant union member to empty struct
authorJonathan Wakely <jwakely@redhat.com>
Tue, 19 Oct 2021 10:53:27 +0000 (11:53 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 19 Oct 2021 14:01:16 +0000 (15:01 +0100)
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.

libstdc++-v3/include/std/variant

index d18365fde22d4681a2cf04bb1ba15c7ff0d2771b..3da7dad1e829a5fefef286dd2f2d5b1a8713b48e 100644 (file)
@@ -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