GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc/c

GCC: Harmonize handling of zero-size arrays and flexible array members

Standardizes internal functions for zero-size arrays and flexible array members.

This commit refactors GCC’s C frontend to use common internal functions for creating and detecting zero-size arrays and flexible array members. It introduces a new helper function zero_length_array_type_p and modifies existing ones to consistently handle these types. The change aims to improve code clarity and prepare for future updates that may further unify the representation of these array types.

In Details

The C frontend's handling of zero-length arrays (VLAs as members) and flexible array members (FAMs) has been unified. New helper functions zero_length_array_type_p and c_build_array_type_zero_size are introduced, and existing checks like TYPE_MAX_VALUE == NULL_TREE are replaced with flexible_array_member_type_p. The composite_type_internal function's explicit check for complete types is also removed, potentially generalizing its behavior for arrays with incomplete element types.

For Context
flexible array member
A C99 feature allowing the last element of a struct to be an array of incomplete type, commonly used for dynamic-sized data structures.
zero-size array
An array declared with zero elements. In C, this typically refers to a VLLA (Variable Length Array) with a size expression evaluating to zero, or a flexible array member.
VLAs
Variable Length Arrays. Arrays whose size is determined at runtime, declared with a size expression other than a constant integer.
struct
A composite data type in C/C++ that aggregates variables of potentially different data types under a single name.
struct `composite_type_internal`
An internal GCC function likely involved in constructing and verifying the type information for composite data types like structs and unions.
Filed Under: ctype system