, UB. , :
#include <stdio.h>
#define IMAX_BITS(m) ((m) /((m)%0x3fffffffL+1) /0x3fffffffL %0x3fffffffL *30 \
+ (m)%0x3fffffffL /((m)%31+1)/31%31*5 + 4-12/((m)%31+3))
#define UINT_BITS IMAX_BITS((unsigned)-1)
int main(void)
{
unsigned int foo = 42;
printf("%d", foo << UINT_BITS);
return 0;
}
, :
$ gcc -std=c11 -Wall -Wextra -pedantic -oshift shift.c
shift.c: In function 'main':
shift.c:11:22: warning: left shift count >= width of type [-Wshift-count-overflow]
printf("%d", foo << UINT_BITS);
^~
$ ./shift
42