Fix undefined behavior from sequence point rule violations.

Hi,

Here are some fixes that remove undefined behavior. See commit message for details, and here for more information:

http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wsequence_002dpoint-309