Why does left shifting unsigned int
32 times generates below warning?
pthr.c: In function ‘main’:
pthr.c:4: warning: left shift count >= width of type
Even though sizeof(unsigned int)
is 4 bytes on my system.
Code:
#include<stdio.h>
int main(void)
{
unsigned int mask = 1u << 32;
printf("sizeof(unsigned int) = %u\n", sizeof(unsigned int));
return 0;
}
gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.