GCC and pointer overflows
Posted Apr 16, 2008 20:58 UTC (Wed) by
JoeBuck (subscriber, #2330)
In reply to:
GCC and pointer overflows by iabervon
Parent article:
GCC and pointer overflows
The compiler then would have to insert such a check into every array reference in a loop, and your code would run about 3x slower. After
all, they could wrap around the end, right?
But in a properly structured program, such checks are not needed, as
pointers are not random, but rather refer to objects that have definite sizes and that do not wrap around the end of memory. If you think that you need such a check, there's something wrong with your program structure, some check that was omitted elsewhere. What matters is the size of the buffer, and you can go beyond its end without wrapping around the end of the address space.
(
Log in to post comments)