GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: Run block cleanup for unlabeled break and continue

GCC Rust compiler ensures cleanup code runs for unlabeled break and continue statements.

This patch ensures that block cleanup code is executed for unlabeled break and continue statements in GCC’s Rust front-end. Unlabeled break statements now return their translated tree, consistent with continue, and tail-position control flow expressions are emitted as statements to ensure they remain within the TRY_FINALLY_EXPR body.

In Details

The gccrs backend ensures that block cleanup (e.g., running destructors for RAII objects) is correctly executed for unlabeled break and continue statements. Previously, unlabeled break might have been handled differently than continue. This change makes break return its translated tree, matching continue's behavior. Additionally, tail-position break and continue expressions are now emitted as statements, guaranteeing they are enclosed within TRY_FINALLY_EXPR's body, thus invoking necessary cleanup logic.

For Context
unlabeled break
A break statement used within a loop or a match expression that does not specify which construct to exit. It exits the innermost enclosing loop or match.
TRY_FINALLY_EXPR
An intermediate representation construct, likely used in gccrs, that guarantees the execution of a 'finally' block (containing cleanup code) regardless of whether exceptions or control flow transfers occur within the 'try' block.
RAII
Resource Acquisition Is Initialization. A programming idiom in C++ and Rust where resource management is tied to object lifetimes. When an object goes out of scope, its destructor is called, releasing the resource.
Filed Under: gccrsrustcompiler backendcontrol flow