Object-oriented design patterns in the kernel, part 1
Posted Jun 2, 2011 14:30 UTC (Thu) by pixelbeat (guest, #7440)
[Link]
Well by my analysis in the above link, GCC does init the padding to zero. I.E. it seems GCC interprets 6.7.8 to trump 6.2.6.
I'd be very interested if there was a counter example in the wild
Object-oriented design patterns in the kernel, part 1
Posted Jun 2, 2011 16:19 UTC (Thu) by juliank (subscriber, #45896)
[Link]
> Well by my analysis in the above link, GCC does init the padding to zero.
Did you actually enable optimizations when testing?
> I'd be very interested if there was a counter example in the wild
Object-oriented design patterns in the kernel, part 1
Posted Jun 3, 2011 1:59 UTC (Fri) by pixelbeat (guest, #7440)
[Link]
> Did you actually enable optimizations when testing?
That is immaterial as optimizations may zero the padding.
The interesting case to test is the non optimized case.
Object-oriented design patterns in the kernel, part 1
Posted Jun 2, 2011 18:00 UTC (Thu) by nix (subscriber, #2304)
[Link]
Well, you could check the code, or (more practically) GCC's intermediate representations, both of which make it fairly clear that GCC emits initializations for every field independently, then subjects them all to optimization just as if you'd written them as separate statements. Sometimes (especially for large structures) this may lead to initializations being merged and blatting over gaps: very often, it does not.