in my little chess engine I get some crash reports from testers running it on their systems. As most of them use a 64 bit system and I don't I wonder whether this can be the cause of trouble.
As the crashes seem to happen when the hash is reset I looked at my code here and ask myself if this is the proper way of coding this
Code: Select all
// enforce memory alignment to 64 byte boundary
// allocate some headroom in buffer and let the actual hash point to a 64 byte aligned address
buffer = (unsigned char *) malloc(sizeof(*hash) + 63);
hash = (THash *) (((uintptr_t) buffer + 63) & ~63);
memset(hash,0,sizeof(*hash));The cast to uintptr_t seems problematic. From the definition uintptr_t
"It is an unsigned int that is guaranteed to be the same size as a pointer."
but this guarantee is only valid at compile time, right ? So when compiling for a 32bit target it will be a 4byte pointer, can this cause a crash when the binary is run on a 64 bit system then ?
If so, is there a better way of coding this (a long long hack or so) or do I have to create a dedicated 32 bit (only) and a 64 bit (only) binary ?
Thanks
Thomas...