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

Adds warnings for potentially-uninitialized padding bits.

Introduces `-Wzero-init-padding-bits=` to warn about code relying on zero-initialized padding, following a change in default behavior.

Following a change that reduced the zeroing of union padding bits, this commit introduces the -Wzero-init-padding-bits= warning. This warning helps programmers identify code that might need recompilation with -fzero-init-padding-bits=unions or -fzero-init-padding-bits=all to maintain compatibility with older GCC versions or to ensure padding is explicitly zero-initialized.

In Details

This commit adds -Wzero-init-padding-bits= and modifies the interaction with -fzero-init-padding-bits. Padding bits within structs and unions are not always guaranteed to be zero-initialized. Recent changes modified when these bits are zeroed by default. This new warning helps detect code relying on the previous behavior.

For Context

In C and C++, structures and unions can have unused bits called padding. Compilers sometimes initialize these bits to zero, but this is not always guaranteed. A recent change in GCC altered when padding bits are zeroed by default. This commit introduces a new warning that alerts programmers to code that depends on padding being zero-initialized, so they can explicitly request this behavior if needed.

Filed Under: warningpaddinginitializationcompatibility