https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94886
Bug ID: 94886 Summary: coroutines: ICE building folly, in transform_local_var_uses, at cp/coroutines.cc:1908 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iains at gcc dot gnu.org Target Milestone: --- Created attachment 48424 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48424&action=edit fix under test the code below should build but produces an ICE this is because the range-based for generates three artificial variables that need to be allocated to the coroutine frame but, when walking the BIND_EXR that contains these, the DECL_INITIAL for one of them refers to an entry appearing later, which means that the frame entry hasn't been allocated when that INITIAL is walked. The solution is to defer walking the DECL_INITIAL/SIZE etc. until all the BIND_EXPR vars have been processed. coro1 my_coro () { const std::array<int, 5> expectedValues = {{0, 3, 1, 4, 2}}; for (int expectedValue : expectedValues) { co_yield expectedValue; } }