[Bug libstdc++/106608] New: [12 Regression] std::optional requires unavailable dtor

egor.pugin at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Aug 13 10:23:30 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106608

            Bug ID: 106608
           Summary: [12 Regression] std::optional requires unavailable
                    dtor
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: egor.pugin at gmail dot com
  Target Milestone: ---

by John Preston

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/dev/Telegram/SourceFiles/passport/passport_panel_edit_scans.h#L38

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/dev/Telegram/SourceFiles/passport/passport_panel_edit_scans.h#L75

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?


More information about the Gcc-bugs mailing list