Use uintptr_t for casting pointers to integers

This fixes compilation on mingw-w64 and makes failing tests pass
on MSVC in 64 bit mode.