Saturday, October 1, 2011

oops

I found this nice, classic "beware of macros" bug:
#define MAX(a, b)    ((a) > (b) ? (a) : (b))
[ ... ]
int x = MAX(foo, bar++); // incremented either once or twice

Oops.