From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 57CA43856DED; Thu, 28 Apr 2022 12:51:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57CA43856DED From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103868] ICE at end of coroutine when using asio Date: Thu, 28 Apr 2022 12:51:26 +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: 11.1.0 X-Bugzilla-Keywords: C++-Coroutine, ice-on-valid-code 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: --- 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: Thu, 28 Apr 2022 12:51:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103868 --- Comment #6 from CVS Commits --- The master branch has been updated by Iain D Sandoe : https://gcc.gnu.org/g:9cb1f565a91e2dd57098c43593954b57c065a19b commit r12-8307-g9cb1f565a91e2dd57098c43593954b57c065a19b Author: Nathan Sidwell Date: Sun Apr 3 11:35:03 2022 +0100 c++, coroutines: Avoid expanding within templates [PR103868] This is a forward-port of a patch by Nathan (against 10.x) which fixes = an open PR. We are ICEing because we ended up tsubst_copying something that had alr= eady been tsubst, leading to an assert failure (mostly such repeated tsubsti= ng is harmless). We had a non-dependent co_await in a non-dependent-type template fn, so= we processed it at definition time, and then reprocessed at instantiation time. We fix this here by deferring substitution while processing templates. Additional observations (for a better future fix, in the GCC13 timescal= e): Exprs only have dependent type if at least one operand is dependent whi= ch was what the current code was intending to do. Coroutines have the additio= nal wrinkle, that the current fn's type is an implicit operand. So, if the coroutine function's type is not dependent, and the operand = is not dependent, we should determine the type of the co_await expression using the DEPENDENT_EXPR wrapper machinery. That allows us to determine the subexpression type, but leave its operand unchanged and then instantiat= e it later. PR c++/103868 gcc/cp/ChangeLog: * coroutines.cc (finish_co_await_expr): Do not process non-dependent coroutine expressions at template definition time. (finish_co_yield_expr): Likewise. (finish_co_return_stmt): Likewise. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr103868.C: New test. Co-Authored-by: Iain Sandoe =