GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gimple-fold

Handle large _BitInt bit-fields in __builtin_clear_padding

GCC's `__builtin_clear_padding` now handles very large `_BitInt` bit-fields, fixing an assertion failure for huge types.

This commit addresses an assertion failure in GCC’s __builtin_clear_padding when processing extremely large bit-fields, particularly those using the _BitInt type. The fix modifies the handling of large bit-fields to avoid overwhelming internal buffers, ensuring that such types can be processed correctly without crashing the compiler.

In Details

The gimple-fold pass's implementation of __builtin_clear_padding encountered issues with large bit-fields (especially _BitInt types) exceeding the capacity of its internal working buffer. The original logic, relying on clear_padding_add_padding, would assert when the number of bytes to clear was too large. This patch refactors the handling for such extreme cases: it limits clear_padding_add_padding to a smaller initial region, then enters a loop to flush and clear larger contiguous blocks, and finally handles the remaining bits. This prevents the assertion and correctly processes ov…

For Context
GIMPLE
GCC's internal three-address code representation, used as an intermediate language between the front-end and back-end optimization passes.
gimple-fold
A GCC optimization pass that performs constant folding and other algebraic simplifications on GIMPLE code.
__builtin_clear_padding
A GCC built-in function (introduced in GCC 11) that clears padding bits within a data structure, setting them to zero. This can be useful for ensuring consistent memory layouts or preparing data for serialization.
_BitInt
A C++23 feature that allows for integer types of arbitrary bit width, providing more flexibility than fixed-width types like int or long long.
bit-field
A data member within a struct or union that is allowed to occupy only a specified number of bits, which may be less than the number of bits in its data type.
Filed Under: optimizationbugfixc++