Re:20 bit operations programmers should know
by asveikau on Saturday June 08, 2013 @09:44AM
(#5844842)
Some people are pointing out undefined behavior involving shifts. I agree it's pretty egregious. (Also, how can you hardcode 31 in a bunch of places, make a statement like "if you don't know how many bytes an int is" - and not mention sizeof!)
But there's a special place in hell reserved for this:
> (a) ^= (b) ^= (a) ^= (b);
This is undefined because ^= is not a sequence point.
I feel like the title of this should be "how to demonstrate lack of C knowledge".
But there's a special place in hell reserved for this:
> (a) ^= (b) ^= (a) ^= (b);
This is undefined because ^= is not a sequence point.
I feel like the title of this should be "how to demonstrate lack of C knowledge".