[Bug c/77992] Failures to initialize padding bytes -- causing many information leaks
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Sun Oct 16 13:48:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77992
--- Comment #10 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
If you care about information in bytes that are not part of a field with
other semantic significance, you should use -Werror=padded to get errors
on structs with padding and use that information to add explicit dummy
fields in the source code where there was padding. Once there are
explicit dummy fields, their values will be preserved by the compiler, so
you can either zero the whole struct with memset and rely on the zeroing
of dummy fields not being optimized away, or use a struct initializer and
rely on it implicitly zeroing those fields. (Of course this may reduce
efficiency as optimizations such as SRA now need to track values of those
fields, whereas they do not need to track values of padding.)
More information about the Gcc-bugs
mailing list