http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49679
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-07-08 17:57:09 UTC --- The code has undefined behaviour because there are no sequence points between the increments, see http://c-faq.com/expr/seqpoints.html GCC even warns you: seq.cc: In function 'int main(int, char**)': seq.cc:19:15: warning: operation on 'a' may be undefined [-Wsequence-point] seq.cc:19:15: warning: operation on 'a' may be undefined [-Wsequence-point] seq.cc:20:15: warning: operation on 'b' may be undefined [-Wsequence-point] seq.cc:20:15: warning: operation on 'b' may be undefined [-Wsequence-point] You should use -Wall if the compiler seems to be doing something you don't understand, it might explain why.