I'm porting my game to Android which has around 200k lines of code and encountered a very strange bug, after 5 hours of digging I cracked it down to this line:
// background info
short m = ((dwMask << 4) | dwMask) << ASTAR_OFFSET_VIS;
short zm = (~ASTAR_MASK_DISCOVERED) | (~dwMask);
short *b = (short*)tilecache.GetDataPtr() + index;
// unexpected behavior
*b++ = (*b&zm) | m;
// works
*b = ((*b)&zm) | m; b++;
My guess is this compiler (GCC ARM) treats the ++ operator differently than all other compilers I've built this game on, which seems a little crazy, but not unbelievable. Previously the game has been built for Windows, Mac, iOS, and Windows CE and all processed the top version fine.
I think it's evaluating (*b&zm) | m then incrementing the pointer b++ then doing the assignment, because data is shifted left in my array each evaluation.
I have located numerous places in my code that use this type of syntax and changed them, but I want to make sure the problem is what I'm thinking it is, and if this is a compiler option I could switch to make it the same as the other compilers I use? In case I have other syntax like this in my code elsewhere.