https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
--- Comment #9 from Pedro Alves <palves at redhat dot com> --- > So maybe we just want to use a #pragma around the std::optional destructor to > suppress this warning. I had tried that last night, but unfortunately it couldn't get it to work, because the warning triggers in A, not optional<A>. Users of optional<T> have to put the #pragma around their the Ts (in this case A::~A()). I.e., this would work: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" struct A { A () : m (get ()) {} ~A () { set (m); } // warns here int m; }; #pragma GCC diagnostic pop I think as we'll use gdb/std::optional more and more, that would become too unwildy/ugly. My current workaround in gdb is -Wno-error=maybe-uninitialized: [1] - https://sourceware.org/ml/gdb-patches/2017-05/msg00130.html