https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114253
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This looks fixed in GCC 15+. Most likely by r15-6052-g12de1942a0a673 and r15-9400-ge7bccec33beece . GCC now zeros out the full std::optional<int> in this case. The missed optimization is still there. Plus there seems like there is another missed optimization with execeptions on and SRA off but I am not 100% sure.
