[Bug middle-end/103839] __builtin_clear_padding doesn't zero alignment holes of unions with fields that overlap padding

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Dec 27 11:10:47 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103839

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The right fix is IMHO to add
#define CONSTRUCTOR_ZERO_PADDING(NODE) \
  (CONSTRUCTOR_CHECK (NODE)->base.protected_flag)
and handle that during gimplification etc.
This is needed both for C++ where 
https://eel.is/c++draft/dcl.init#general-6
requires that zero initialization clears padding bits, so the FE should set
it for zero initialization ctors, and I bet for D as well.
gimplification should then ensure vars initialized by such CONSTRUCTORs have
the padding bits cleared in whatever way is most efficient.


More information about the Gcc-bugs mailing list