Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Integer promotion rules!!!
fabiang@ryg-ivbultra ~/code/uac » cat test.c
#include <stdio.h>
int main()
{
size_t a = ~0;
size_t b = ~0 << 5;
size_t c = ~0 >> 1;
size_t d = ~0u >> 1;
printf("a=0x%zx\n", a);
printf("b=0x%zx\n", b);
printf("c=0x%zx\n", c);
printf("d=0x%zx\n", d);
return 0;
}
fabiang@ryg-ivbultra ~/code/uac » gcc -Wall test.c && ./a.out
a=0xffffffffffffffff
b=0xffffffffffffffe0
c=0xffffffffffffffff
d=0x7fffffff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment