From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 910303856DD3; Mon, 7 Nov 2022 13:41:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 910303856DD3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667828475; bh=HELBfiAECL4xDRUwB++YsJbRGszZE4VtB1faWaI6fVU=; h=From:To:Subject:Date:From; b=J47t+AfURR3urcndUGoVAgy3cpgUd5El4hOyeoIrldVDtzighZX/KKHI7d+XaGQAV fHmOam9cWKh8gxbK4SnY+FIA8pRzt2lS5pvyGYkK1nHcheORsi3W0wJ4RWNvf+XJn3 3I629m/V6pKBMMSt56UgTQXxhyYCoZZHzbsx7eCo= From: "dennis-hezel at gmx dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107556] New: Passing lambda to a coroutine function triggers -Wsubobject-linkage Date: Mon, 07 Nov 2022 13:41:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dennis-hezel at gmx dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107556 Bug ID: 107556 Summary: Passing lambda to a coroutine function triggers -Wsubobject-linkage Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dennis-hezel at gmx dot de Target Milestone: --- Affects GCC 10+ If you think the warning is legitimate then please advise how to change the code. Smallest reproducer I could come up with: https://godbolt.org/z/WvPE1qx8s It is not limited to `co_yield`, `co_await`-compatible coroutines also trig= ger it. Reproducer here incase the compiler explorer link does not work: other.hpp ```c++ #include struct Generator { struct promise_type { Generator get_return_object() { return Generator{}; } std::suspend_always initial_suspend() { return {}; } std::suspend_always final_suspend() noexcept { return {}; } std::suspend_always yield_value(int) { return {}; } void unhandled_exception() {} }; }; template auto invoke_and_await(F) -> Generator { co_yield 1; } auto test() { invoke_and_await([] {}); } ``` main.cpp ```c++ // must be included, copy-pasting the code into here won't trigger it #include "other.hpp" ``` Compiler output: ``` In file included from /app/main.cpp:2: other.hpp: In instantiation of 'Generator invoke_and_await(F) [with F =3D test()::]': other.hpp:23:27: required from here other.hpp:19:1: warning: 'invoke_and_await >::_Z16invoke_and_awaitIZ4testvEUlvE_E9GeneratorT_.frame' has a field 'invoke_and_await >::_Z16invoke_and_awaitIZ4testvEUlvE_E9GeneratorT_.frame::__unnamed_parm.0' whose type has no linkage [-Wsubobject-linkage] 19 | } | ^ ``` Compile with `-fcoroutines` before GCC version 11.=