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

c++: Fix lambda scope cleanup after class error

Ensures correct lambda scope cleanup when a class definition fails.

When a class definition fails parsing in GCC’s C++ front-end, the lambda scope cleanup was not correctly handled, leading to incorrect active scope information. This commit modifies the parser to track whether a lambda scope was opened for a class head, ensuring proper cleanup regardless of the class definition’s success. This fixes PR125343.

In Details

GCC's C++ parser opens a lambda mangling scope when encountering a class head. If begin_class_definition subsequently rejects the class (e.g., due to a syntax error), it replaces the class head with error_mark_node. Previously, the scope cleanup logic did not account for this rejection, leaving the lambda scope incorrectly active. This change introduces a flag to track the opening of a lambda scope specifically for a class head, ensuring that the scope is properly closed even when the class definition fails.

For Context
lambda scope
A scope related to the parsing and mangling of lambda expressions in C++. Proper management of these scopes is crucial for correct compilation and linking.
error_mark_node
A special node in GCC's internal representation indicating a parsing or semantic error. It allows the compiler to continue parsing to find more errors rather than aborting immediately.
mangling
The process of encoding C++ function and variable names to include type information, allowing the linker to distinguish between entities with the same name but different signatures.
Filed Under: c++parserlambda