Skip to content

Clang + libstdc++-16 fail: no matching member function for call to 'emplace' #29939

Description

@AngryLoki

Steps to reproduce

Hi, there is some new code which fails to compile when compiler is set to clang-21 with newest libstdc++-16 (from git):

/var/tmp/portage/net-im/telegram-desktop-6.2.3/work/tdesktop-6.2.3-full/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp:1406:23: error: no matching member function for call to 'emplace'
 1406 |                 _botFullWaitingArgs.emplace();
      |                 ~~~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/16/include/g++-v16/optional:1126:2: note: candidate template ignored: requirement 'is_constructible_v<InlineBots::WebViewInstance::ShowArgs>' was not satisfied [with _Args = <>]
 1126 |         emplace(_Args&&... __args)
      |         ^
/usr/lib/gcc/x86_64-pc-linux-gnu/16/include/g++-v16/optional:1138:2: note: candidate function template not viable: requires at least argument '__il', but no arguments were provided
 1138 |         emplace(initializer_list<_Up> __il, _Args&&... __args)
      |         ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Apparently, as InlineBots::WebViewInstance::ShowArgs is private nested struct, it is not considered as constructible, see https://stackoverflow.com/questions/60490574/stdis-constructible-returns-inconsistent-value-for-private-constructor

One possible solution is to use _botFullWaitingArgs = ShowArgs{};, see attached PR.

Also please check and merge related PR TelegramMessenger/tgcalls#50, if you want to compile it.

Expected behaviour

It compiles.

Actual behaviour

It fails to compile.

Operating system

Gentoo

Version of Telegram Desktop

6.2.3

Installation source

Other (unofficial) source

Crash ID

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions