https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105595
Bug ID: 105595 Summary: Coroutines can trigger -Wsubobject-linkage Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: blubban at gmail dot com Target Milestone: --- To reproduce: - Create a minimal coroutine promise - Create a coroutine where any local's type has no linkage (for example a lambda) - #include the above from another, differently named, file Result: /app/not_example.cpp:25:1: warning: 'foo()::_Z3foov.Frame' has a field 'foo()::_Z3foov.Frame::anon_ns_1_2' whose type uses the anonymous namespace [-Wsubobject-linkage] /app/not_example.cpp:25:1: warning: 'foo()::_Z3foov.Frame' has a field 'foo()::_Z3foov.Frame::inner_class_1_2' whose type has no linkage [-Wsubobject-linkage] /app/not_example.cpp:25:1: warning: 'foo()::_Z3foov.Frame' has a field 'foo()::_Z3foov.Frame::a_lambda_1_2' whose type has no linkage [-Wsubobject-linkage] Expected: No warning, because the coroutine frame's type shouldn't have linkage either. Sticking anonymous types inside each other is harmless. Full testcase: # 2 "/app/not_example.cpp" 1 #include <coroutine> class async { public: class promise_type { public: async get_return_object() { return {}; } std::suspend_never initial_suspend() { return {}; } std::suspend_never final_suspend() noexcept { return {}; } void unhandled_exception() {} }; }; namespace { class anon_ns_t {}; } async foo() { anon_ns_t anon_ns; class inner_class_t {} inner_class; auto a_lambda = [](){}; co_await std::suspend_never{}; } Compile with -std=c++20. Compiler Explorer: https://godbolt.org/z/efz6dfoWq