https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106608
--- Comment #1 from Egor Pugin <egor.pugin at gmail dot com> --- Update links. === We've tried to build Telegram Desktop with GCC 12 and got such error: http://paste.mva.name/co36VoGr.txt There is a struct A { vector<B> b; }, where B is a declared, but not defined struct: https://github.com/telegramdesktop/tdesktop/blob/d63e50944a7949ffffa0ecd5113d5ef82166eafc/Telegram/SourceFiles/passport/passport_panel_edit_scans.h#L28-L40 In the same header later in a method there is am argument of type optional<A> with a default value nullopt: https://github.com/telegramdesktop/tdesktop/blob/d63e50944a7949ffffa0ecd5113d5ef82166eafc/Telegram/SourceFiles/passport/passport_panel_edit_scans.h#L75-L77 When I read the error text that the compiler gave me (link above) I see, that it wants to instantiate this constructor: constexpr std::_Optional_base<Passport::ScanListData, false, false>::_Optional_base() = default; and for that it tries to instantiate (why? what for?) this destructor method: std::_Optional_payload<Passport::ScanListData, false, false, false>::~_Optional_payload Which of course it can't instantiate, because the destructor of ScanListData is not available in that place of the code, this struct is not defined yet. But why does it need this destructor? This constructor of optional(nullopt_t) never calls this destructor. All major compilers (MSVC, GCC, Clang) of all (tried) modern versions (in case of GCC — before 12) build this code without problems. Is this a GCC regression? ===