test.cc: In function 'int main()':
test.cc:11:36: warning: operation on 'a' may be undefined [-Wsequence-point]
test.cc:12:35: warning: operation on 'a' may be undefined [-Wsequence-point]
test.cc:16:36: warning: operation on 'b' may be undefined [-Wsequence-point]
test.cc:17:35: warning: operation on 'b' may be undefined [-Wsequence-point]
Both modifying the same scalar variable twice without synchronization (lines 11 and 16) and modifying and reading the same scalar variable without synchronization (lines 12 and 17) are explicitly undefined in C++ (or in C, for that matter). Executing an undefined program can give any results whatsoever.
OK, thanks, Cubbi. Visual studios doesn't report any errors (that I know how to detect, anyhow). How were you able to find those errors?
This is for a C++ lab out of a 7th edition textbook that I'm using to take a college course... One would hope those errors would have been caught by now, lol.