https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101133
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Iain D Sandoe <ia...@gcc.gnu.org>: https://gcc.gnu.org/g:1b54a7226368bf86361e5c9d8ae523193037a0ac commit r12-4100-g1b54a7226368bf86361e5c9d8ae523193037a0ac Author: Iain Sandoe <i...@sandoe.co.uk> Date: Sat Oct 2 13:40:09 2021 +0100 coroutines: Ensure co_await_exprs have TREE_SIDE_EFFECTS set [PR 101133]. Although it is not immediately evident from the symptoms, the PR is caused by a variable having a DECL_INITIAL() containing a co_await. This is not correct, since such expressions have side-effects. We were marking the overall co_await expression correctly, but if a consumer of that expression stripped out the underlying co_await_expr then the latter would not be properly marked. Fixed by marking both the underlying and any containing await expr with TREE_SIDE_EFFECTS. Also mark type-dependent co_await expressions. Signed-off-by: Iain Sandoe <i...@sandoe.co.uk> PR c++/101133 gcc/cp/ChangeLog: * coroutines.cc (build_co_await): Mark co_await_expr trees with TREE_SIDE_EFFECTS, also mark any containing expression. (finish_co_await_expr): Mark type-dependent co_await_expr trees with TREE_SIDE_EFFECTS. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr101133.C: New test.