3 ms·
> Treating a pointer as an integer in order to mess with the bits is also a violation. Violation of what exactly? Converting a pointer to an integer, and vice
by nemetroid 8y ago
> Treating a pointer as an integer in order to mess with the bits is also a violation.
Violation of what exactly? Converting a pointer to an integer, and vice versa, is implementation defined. As long as you're not trying to write implementation-independent code, it's perfectly fine.
- burfog 8y agoSure, you can convert, but the whole point of converting is to do things that violate the C standard. In theory, a standard-conforming C implementation could have the bits of a pointer be encrypted by the CPU. There is nothing meaningful that you could do to those bits. Rounding pointers up or down for alignment is impossible in standards-conforming C code.