From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 984EB384B833; Fri, 13 May 2022 16:21:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 984EB384B833 From: "blubban at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105595] New: Coroutines can trigger -Wsubobject-linkage Date: Fri, 13 May 2022 16:21:12 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: blubban at gmail dot com 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2022 16:21:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105595 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 eithe= r. Sticking anonymous types inside each other is harmless. Full testcase: # 2 "/app/not_example.cpp" 1 #include 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 =3D [](){}; co_await std::suspend_never{}; } Compile with -std=3Dc++20. Compiler Explorer: https://godbolt.org/z/efz6dfoWq=