Following code produces unexpected result (0) for BITS=16:
#define BITS 16
#define MOD(x) ((x) & ((1 << BITS) - 1))
int v = 5;
int main()
{
printf("%d\n", MOD(v));
}
More discussion is at https://sourceforge.net/mailarchive/message.php?msg_id=30751567
Despite shifts to values bigger than bit size of type are undefined per C standard, there're:
1) Arithmetical definition of shift operation;
2) Behavior of other well-known gcc ports (x86);
3) User expectations;
4) Principle of least surprise.
So, it would be nice to change compile-time (and only compile-time!) behavior to more consistent with mathematical definition.
This is obviously not a priority request.