Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Technically no, a pointer pointing outside of its array (or similar) at any point is undefined behaviour. More importantly for this discussion, without support from the language it's not very ergonomic to work with. What happens when you need to call strlen, memcpy, or free?


It works in this case where you want to move the zero index forward a few cells to a valid offset. It is only UB for the general case where the offset may land outside valid memory. C has always supported negative indices, so moving index zero forward into the middle of the array is fine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: