https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128302
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:7002faa756a0f60fe28c206620c777112755f94d commit r17-6487-g7002faa756a0f60fe28c206620c777112755f94d Author: Jakub Jelinek <[email protected]> Date: Fri Nov 20 09:17:29 2026 +0100 gimple-fold: Handle bit-fields in unions correctly during __builtin_clear_padding [PR128302] Clear padding in unions is special, we basically compute bitmask which bits aren't padding (0s) and which are padding (1s) for each union member individually and using clear_padding_flush then and it together because we don't know which union member is active, so only padding bits for all the union members are cleared. This PR reports that I forgot to handle bit-fields in there. This patch fixes it by outlining most of the DECL_BIT_FIELD handling from the RECORD_TYPE loop in clear_padding_type into a new function and using it also in clear_padding_union instead of just calling clear_padding_type as if it wasn't a bit-field. 2026-11-20 Jakub Jelinek <[email protected]> PR middle-end/128302 * gimple-fold.cc (clear_padding_bitfield): New function, mostly moved code from clear_padding_type. (clear_padding_union): Use it to handle DECL_BIT_FIELD inside of a union. (clear_padding_type): Handle DECL_BIT_FIELD using the outlined new clear_padding_bitfield function. * gcc.dg/builtin-clear-padding-3.c: New test. Reviewed-by: Richard Biener <[email protected]>
