https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114285

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xry111 at gcc dot gnu.org

--- Comment #9 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Antoni from comment #8)
> Created attachment 57726 [details]
> Reproducer using union
> 
> I tried switching to a union and I still get the same error.
> 
> A union is used by std::optional, so I would assume that this should work.
> Or is copying uninitialized memory via a union also UB?

Yes.

std::optional copy constructor is not a default copy constructor.  It does not
copy if the input is nullopt.

Reply via email to