/* C program below. This mail can be extracted into test.c
on x86, sizeof(long long) == 8, sizeof(long) == 4 gcc -O2 -S test.c hash: pushl %ebp movl %esp, %ebp subl $8, %esp movl -4(%ebp), %eax xorl -8(%ebp), %eax leave ret Where did the ull = *(unsigned long long *)key; assignment go? The compiler allocates stack space, and uses it, but without putting anything into it first. The asm generated without optimisation (without -O2) is correct. Debian Linux Pentium 4 system, gcc installed from package system from unstable as of 9 Nov 2004. gcc -O2 -S test.c no messages are generated at compilation. gcc 2.95 generates correct code. gcc 3.2.3 fails gcc 3.3.5 fails gcc 3.4.2 fails /Anders Torger */ #include <stdio.h> unsigned long hash(void *key) { unsigned long long ull; ull = *(unsigned long long *)key; return ((unsigned long *)&ull)[0] ^ ((unsigned long *)&ull)[1]; } int main(void) { unsigned long long ull; ull = ~0; fprintf(stderr, "%u\n", hash(&ull)); return 0; }