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

It is an obvious simplification, but his boss is wrong. The order of uninitialized variables can be changed by the compiler. For example to better package the variables due to an alignment requirements. E.g. allocating

  char a;
  long b;
  char c;
  short d;
on a RISC-style platform as "a,c,d,b" requires 8 bytes, while as a,b,c,d - 12. This may not matter in a majority of cases, but it some it does.


For homogenous variables (like two "int"s), I don't think you could make a strong argument for the compiler reordering them.


Some advanced optimization may benefit from this sort of reordering. Alternatively, a compiler that reorders all local variables for "security" purposes may mix even just two ints if it's implemented in a dumb way.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: