https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752

--- Comment #26 from Chung-Kil Hur <gil.hur at sf dot snu.ac.kr> ---
Thanks for the detailed explanations.

> The C standard only guarantees that you can convert a pointer to uintptr_t
> and back, it doesn't guarantee that you can convert a modified uintptr_t
> back to
> a pointer that is valid.
> 
> Thus, doing (int *)((xp + i) - j) is invoking undefined behavior.
> 

I didn't know about this rule.
I thought this cast is valid because "(xp+i)-j" is even "safely-derived".

Could you give a reference for that rule in the standard?

Thanks!

Reply via email to