https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106188
Bug ID: 106188 Summary: [11.3 Regression] [coroutines] Incorrect frame layout after transforming conditional statement without top-level bind expression Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc-bugzilla at decltype dot org Target Milestone: --- Created attachment 53257 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53257&action=edit Minimal test case During `morph_fn_to_coro`, `await_statement_walker` rewrites IF and SWITCH statements by breaking the condition out into a local variable. The new variable is inserted at the beginning of the containing bind expression. If the original function lacked a top-level bind expression, this pushes the resume function pointer and all following fixed-layout frame members away from their intended placement. Expected frame layout: _Coro_resume_fn _Coro_destroy_fn _Coro_promise _Coro_self_handle params _Coro_resume_index _Coro_frame_needs_free _Coro_initial_await_resume_called locals (ifcd/swch) Actual frame layout (since 11.3.0): locals (ifcd/swch) <- out of place _Coro_resume_fn _Coro_destroy_fn _Coro_promise _Coro_self_handle params _Coro_resume_index _Coro_frame_needs_free _Coro_initial_await_resume_called The attached program triggers this error and crashes. Uncommenting the unused local variable resolves the crash.