Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C99 TC3 §6.7.2.1p13 "structure and union specifiers":

"Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared."



The as-if rule allows compilers to perform this optimization, provided they elide the optimization for those structs that have addresses of members taken/used, though. This requires whole program analysis of course (as in clang / gcc "LTO" compilation mode). And of course there could be language extensions to loosen this rule further on a per-struct basis.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: