https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115229
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- >Could someone help me understand why this warning is even shown? The lifetime of the temporary (of type B) returned from f is at the end of the full expression. B::value_or's return in theory could have a reference to this (in this case it is not but GCC does not do any analaysis of B::value_or to see that).