Hacker News new | past | comments | ask | show | jobs | submit login

Clang appears to have -Warray-bounds-pointer-arithmetic for this, though not enabled on -Wall nor -Wextra. (fwiw, clang has -Weverything to turn on literally every warning, including conflicting ones, for finding what flags there are)



Yeah, Clang warns on x[20] but not *(x+20) even with -Wall and -O2. It's kinda weird.


Ah, the -Warray-bounds-pointer-arithmetic warning is actually just about the pointer addition; thus even that doesn't warn on *(x+10) on the 10-element array, as the construction of the past-the-end pointer is still valid, and seemingly no warning checks bounds validity for actual dereference.




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

Search: