https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
--- Comment #16 from Pedro Alves <palves at redhat dot com> --- (In reply to Martin Sebor from comment #15) > Zero > initializing A::i first and then setting it to the result of f() also avoids > the warning and seems like more viable solution/workaround until GCC gets > smarter about exceptions. Recall that this C in this case is an std::optional. Basically any random type wrapped in a std::optional can trigger issues like these. A workaround for C in A may be quite tricky -- A may not be default constructible, and the problem may appear in some of A's subobjects recursively. Or A may a class that isn't under the user's control. A workaround in C would be much better. Memsetting the buffer in C's ctor works, but the downside is that that likely has a run time cost, which seems undesirable for std::optional.