GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

c: Fix use of variably-modified structure/union types in nested context

Nested functions now correctly handle variably-modified structure/union types that depend on the enclosing context.

The compiler now correctly handles variably-modified structure and union types within nested functions when those types depend on the enclosing function’s context. The TYPE_STUB_DECLs are now marked as used, ensuring that the static chain is correctly established for accessing variables in the enclosing scope. This fixes a bug where nested functions would fail to access variably-modified types correctly, potentially leading to incorrect code generation or runtime errors.

In Details

This commit addresses PR124985 by ensuring that TYPE_STUB_DECLs are marked as used in c-decl.cc during declspecs_add_type. This is necessary for nested functions that use variably-modified structure or union types depending on the enclosing context, ensuring the correct static chain is established. The comment in c-decl.cc (pushtag) is also updated.

For Context

This commit fixes a bug in the C compiler that arises when using complex data structures (specifically, structures or unions whose size varies at runtime) inside functions defined within other functions. The compiler needs to keep track of how to access variables in the surrounding function. This change ensures that the compiler correctly handles these variable-sized structures in nested functions, preventing potential errors when the program is run.

Filed Under: cnested functionsvariably-modified typesbugfix