Re:How to write cross-platform code
by TheNewAndy on Saturday October 23, 2010 @12:57AM
(#1822689)
Yes, that is another classic one. And this one I think will hit people even when they aren't doing embedded stuff. I seem to recall a compiler optimisation which would make the assumption that the shift count would be well defined, and so it could then do some other optimisation (e.g. maybe that shift count was then used in a loop later, you can then assume that the loop runs less than 31 times)
Also in your example, you should have said sizeof(int)*CHAR_BIT == 32 :)
Also in your example, you should have said sizeof(int)*CHAR_BIT == 32 :)