I'm not sure of what he is doing (what is FindPattern()? how do you know what it is? what does it return? how do you know what it does return?), but why do you need an uintptr_t / intptr_t, if not for pointer arithmetics? That's why they do exist (they convert your pointer to an integer to flip their bits, XOR them, etc. - and it can be NEGATIVE when converted in a signed long). If you don't need this numeric value, why do you use those types?) - if I didn't need to do pointer arithmetics, I would perfectly have used an unsigned long/long/int32_t/uint32_t/int64_t/uint64_t (depending on your implementation), or for example assuming that function returns a DWORD I would have used a DWORD - or if I want, I could just use auto. But as I've already said, _when_ just storing an address, it's better to use void*, still better than having big data types like intptr_t/uintptr_t to hold addresses.
It's hard to understand what he is trying to do. So I'd suggest a site for OP: http://xyproblem.info/ⓘ
It gets converted to an integer which can be negative. Following your reasoning, intptr_t shouldn't even exist, which is wrong as intptr_t doesn't work with actual addresses, but with the integer converted one. As I've already said, it's unclear what OP is trying to do. When he needs to use intptr_t instead of uintptr_t for pointer arithmetics, he must use it.
The minimum size of intptr_t is sizeof(void*), 4 bytes (32 bit) - the maximum size is not defined by the standard, but it is for sure 4GB (it's the same for uintptr_t, so you are incorrect). After 2GB you get the negative value on intptr_t, where is the roblem of the crash? Please, elaborate. The addressable space is 4GB.
?
Bitshifting is another example. In this sentence I wasn't referring to bitshifting, but to rightshifting:
you need to use the correct signed or unsigned type for tagged pointers to get the rightshift.
other than this, it's plausible you are proving you are prig, be more respectful and reply with humility (which is the keyword beyond every programmer) to deserve an answer.
It's hard to understand what he is trying to do. So I'd suggest a site for OP: http://xyproblem.info/ⓘ
Using an intptr_t doesn't make any sense, since, you said it yourself, a pointer can't be negative
The minimum size of intptr_t is sizeof(void*), 4 bytes (32 bit) - the maximum size is not defined by the standard, but it is for sure 4GB (it's the same for uintptr_t, so you are incorrect). After 2GB you get the negative value on intptr_t, where is the roblem of the crash? Please, elaborate. The addressable space is 4GB.
?
When working with pointers, you won't use bitshifting, and if you'll ever ever use it, you can just cast your pointer to an integral type.
you need to use the correct unsigned or signed type to get for example the correct shift.
other than this, it's plausible you are proving you are prig, be more respectful and reply with humility (which is the keyword beyond every programmer) to deserve an answer.
