https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101586
--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:117a880acb67e06caf06d83469d64a698927e719 commit r11-8805-g117a880acb67e06caf06d83469d64a698927e719 Author: Jakub Jelinek <ja...@redhat.com> Date: Tue Jul 27 09:59:37 2021 +0200 gimple-fold: Fix up __builtin_clear_padding on classes with virtual inheritence [PR101586] For the following testcase, B is 16-byte type, containing 8-byte virtual pointer and 1-byte A member, and C contains two FIELD_DECLs, one with B type and size of just 8-byte and then a field with type A and 1-byte size. The __builtin_clear_padding code was upset about the B typed FIELD_DECL containing FIELD_DECLs beyond the field size and triggered assertion failure. This patch makes it ignore all FIELD_DECLs that are (fully) beyond the sz passed from the caller (except for the flexible array member diagnostics that is kept). 2021-07-27 Jakub Jelinek <ja...@redhat.com> PR middle-end/101586 * gimple-fold.c (clear_padding_type): Ignore FIELD_DECLs with byte positions above or equal to sz except for diagnostics of flexible array members. * g++.dg/torture/builtin-clear-padding-4.C: New test. (cherry picked from commit a21bd3cebd6f54af70a37c18b8fbeae933fb6515)