Re:Google interview questions - fun brain teasers
by huhtenberg on Monday August 04, 2008 @10:48PM
(#267089)
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
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.
[ Parent
| on HN ]
Re:Google interview questions - fun brain teasers
by aston on Tuesday August 05, 2008 @12:01AM
(#267129)
For homogenous variables (like two "int"s), I don't think you could make a strong argument for the compiler reordering them.
Re:Google interview questions - fun brain teasers
by huhtenberg on Tuesday August 05, 2008 @12:21AM
(#267146)
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.