public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dennis-hezel at gmx dot de" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-107556-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107556 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 trigger it. Reproducer here incase the compiler explorer link does not work: other.hpp ```c++ #include <coroutine> 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 <class F> 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 = test()::<lambda()>]': other.hpp:23:27: required from here other.hpp:19:1: warning: 'invoke_and_await<test()::<lambda()> >::_Z16invoke_and_awaitIZ4testvEUlvE_E9GeneratorT_.frame' has a field 'invoke_and_await<test()::<lambda()> >::_Z16invoke_and_awaitIZ4testvEUlvE_E9GeneratorT_.frame::__unnamed_parm.0' whose type has no linkage [-Wsubobject-linkage] 19 | } | ^ ``` Compile with `-fcoroutines` before GCC version 11.
next reply other threads:[~2022-11-07 13:41 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-07 13:41 dennis-hezel at gmx dot de [this message] 2022-11-07 16:53 ` [Bug c++/107556] " pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107556-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).