--- Comment #13 from Kangjie Lu <kjlu at gatech dot edu> ---
(In reply to from comment #10)
> 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.)

This is a candidate solution, but I think it cannot scale.  
Given that the Linux kernel has tens of thousands of modules, the idea of 
manually initializing padding bytes for all data structures will be definitely 
declined by the Linux community. 

My opinion is still that, as padding is introduced by compilers and is 
"invisible" to developers, initializing padding should be done by on the 
compiler side.

Reply via email to