https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #29 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Pedro Alves from comment #0)
> union
> {
> int m_dummy;
> T m_item;
Here, changing m_dummy to be unsigned char[sizeof(T)] (or std::byte instead of
unsigned char), so that the buffer starts fully zero-initialized, avoids the
warning. Similarly, in msebor's comment #15 testcase, having the C constructor
initialize x instead of t avoids the warning. For some reason, this isn't
working for me with actual std::optional.