From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 50C4C385781A; Mon, 22 Mar 2021 22:04:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50C4C385781A From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95616] [coroutines] coroutines with potentially-throwing 'co_await promise.final_suspend()' expressions should be ill-formed Date: Mon, 22 Mar 2021 22:04:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.1.1 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: iains at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: Mon, 22 Mar 2021 22:04:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95616 --- Comment #5 from CVS Commits --- The releases/gcc-10 branch has been updated by Iain D Sandoe : https://gcc.gnu.org/g:00f703000fea2e8384f643413b53baa66ec4ddc2 commit r10-9513-g00f703000fea2e8384f643413b53baa66ec4ddc2 Author: Iain Sandoe Date: Mon Feb 15 17:11:31 2021 +0000 coroutines : Do not accept throwing final await expressions [PR95616]. From the PR: The wording of [dcl.fct.def.coroutine]/15 states: * The expression co_await promise.final_suspend() shall not be potentially-throwing ([except.spec]). See http://eel.is/c++draft/dcl.fct.def.coroutine#15 and http://eel.is/c++draft/except.spec#6 ie. all of the following must be declared noexcept (if they form part of the await-expression): - promise_type::final_suspend() - finalSuspendObj.operator co_await() - finalSuspendAwaiter.await_ready() - finalSuspendAwaiter.await_suspend() - finalSuspendAwaiter.await_resume() - finalSuspedObj destructor - finalSuspendAwaiter destructor This implements the checks for these cases and rejects such code with a diagnostic if exceptions are enabled. Backported from 9ee91079fd5879cba046e452ab5593372166b2ab and 4e252e23d34932f13f39cc6544bf5c9379fa2a87 gcc/cp/ChangeLog: PR c++/95616 * coroutines.cc (coro_diagnose_throwing_fn): New helper. (coro_diagnose_throwing_final_aw_expr): New helper. (build_co_await): Diagnose throwing final await expression components. Look through NOP_EXPRs inbuild_special_member_call return value to find the CALL_EXPR. Simplify. (build_init_or_final_await): Diagnose a throwing promise final_suspend() call. gcc/testsuite/ChangeLog: PR c++/95616 * g++.dg/coroutines/pr95616-0-no-exceptions.C: New test. * g++.dg/coroutines/pr95616-0.C: New test. * g++.dg/coroutines/pr95616-1-no-exceptions.C: New test. * g++.dg/coroutines/pr95616-1.C: New test. * g++.dg/coroutines/pr95616-2.C: New test. * g++.dg/coroutines/pr95616-3-no-exceptions.C: New test. * g++.dg/coroutines/pr95616-3.C: New test. * g++.dg/coroutines/pr95616-4.C: New test. * g++.dg/coroutines/pr95616-5.C: New test. * g++.dg/coroutines/pr95616-6.C: New test. Co-authored-by: Jakub Jelinek =