diff --git a/rangecheck.h b/rangecheck.h index 70b0f3f..137be58 100644 --- a/rangecheck.h +++ b/rangecheck.h @@ -16,12 +16,9 @@ __static inline int range_ptrinbuf(const void* buf,size_t len,const void* ptr) { register const char* c=(const char*)buf; /* no pointer arithmetic on void* */ return (c && /* is buf non-NULL? */ -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 1) - ((uintptr_t)c)+len>(uintptr_t)c && /* gcc 4.1 miscompiles this test */ -#else - c+len>c && /* catch integer overflows and fail if buffer is 0 bytes long */ + ((uintptr_t)c)+len>(uintptr_t)c && /* gcc 4.1 miscompiles without (uintptr_t) */ + /* catch integer overflows and fail if buffer is 0 bytes long */ /* because then ptr can't point _in_ the buffer */ -#endif (uintptr_t)((const char*)ptr-c)=(uintptr_t)buf); /* gcc 4.1 miscompiles this test */ -#else - return (buf && (const char*)buf+len>=(const char*)buf); -#endif + return (buf && (uintptr_t)buf+len>=(uintptr_t)buf); } /* is buf2[0..len2-1] inside buf1[0..len-1]? */