News for hackers. Stuff that matters.
Re:Undefined behavior in C is a reading error by magnostherobot on Thursday May 20, 2021 @04:04PM (#27226423)
Do you have an example of a situation in which you'd want to cast the result of arithmetic intptr_t values to a pointer? The situations I can think of off the top of my head would be better done as arithmetic between pointers.
Re:Undefined behavior in C is a reading error by bonzini on Thursday May 20, 2021 @04:18PM (#27226627)
Arithmetic on pointers in turn is only defined if the pointers point within the same object (or right past the end of that object).

One example of using intptr_t would be going from a pointer passed to free() to a metadata block for the memory that must be freed.