I should be more clear. Because there's no "one before" rule, then "buffer + len < buffer" will always be false in a correct program. A correct program would not attempt to derive an invalid pointer (let alone access an object through such a pointer). It's worth noting that "buffer" is the actual object, not merely a pointer. This is an instance where we can't forget that arrays and pointers in C really are distinct, even though we can so often treat an array like a pointer. And the compiler in this instance has sufficient information about the object to make the optimization, whereas in many other instances it would not be able to do this (and so people get the wrong impression). This is a good thing.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds