
On December 24, 2012 8:16:13 PM "Domagoj Saric" <dsaritz@gmail.com> wrote:
If we realize that protected memory systems have page-size-granularity which is much larger than any conceivable SIMD vector size it immediately follows that "overread" (reading outside of the specified range) of a maximum size of "SIMD-cardinal - 1" is always safe. Further more in a single threaded case or when you allocate your arrays with both their location and size aligned, overwrite is also always safe when you wrap the overwrite in a guard class that automatically aligns the array pointers/iterators and then simply restores any possibly overwritten elements in its destructor.
[snip] Call me old-fashioned but this would be an abomination. Every memory checking tool will righteously raise a red flag on such code. In some cases the overread garbage can also affect the processing result, so it cannot be used as a general solution. Even if you provide such behavior, please, don't make it a default and make it very explicit. I'm prepared to have a somewhat slower tail processing, it won't be a deal-breaking slowdown anyway. And if it will, I will probably overallocate memory and fill the tail with neutral data and avoid the undefined behavior.