https://gcc.gnu.org/g:5422486d4bc728688dd2c874cb014fadf745b2da
commit r15-11365-g5422486d4bc728688dd2c874cb014fadf745b2da Author: Alexandre Oliva <[email protected]> Date: Fri Apr 3 18:09:20 2026 -0300 c++: coroutines: initialize refcount If the promise ctor throws, the EH cleanup will access refcount before it is initialized. Initialize it to zero so that cleanups can take place. This seems very hard to hit on systems that ensure the stack starts out zero-initialized, but on VxWorks in kernel mode, this hits more often than not on various architectures. for gcc/cp/ChangeLog * coroutines.cc (cp_coroutine_transform::build_ramp_function): Zero-initialize refcount. (cherry picked from commit 7d7cbf984e4a26d6b6f5098c7e4adb12a427eb4a) Diff: --- gcc/cp/coroutines.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 49aa2ead58c6..e9cdcbabd26e 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -5119,7 +5119,9 @@ cp_coroutine_transform::build_ramp_function () tree coro_frame_refcount = coro_build_and_push_artificial_var_with_dve (loc, coro_frame_refcount_id, short_unsigned_type_node, - orig_fn_decl, NULL_TREE, + orig_fn_decl, + build_int_cst + (short_unsigned_type_node, 0), deref_fp); /* Cleanup if both the ramp and the body have finished. */ tree cond
