[1] bonus point: for what kind of alignment? (The minimum is quite well specified, for C standards)
[1] bonus point: for what kind of alignment? (The minimum is quite well specified, for C standards)
"The address of a block returned by malloc or realloc in GNU systems is always a multiple of eight (or sixteen on 64-bit systems)."
I was about to say, "what if they're on a 32-bit system and so were only allocated one 8-byte block?" but then realized that since they'd requested 9 bytes, they'd be given two 8-byte blocks, or one 16-byte block on a 64-bit system. Is that right?
It tells you where something can't be, and because virtual memory is allocated in whole pages the "padding" so to speak will always be accessible.
There's also the obvious truism that if you can access something in a cache line, all addresses in the cache line are safe to access. (Vectorized algorithms frequently implicitly rely on this for short reads, IOW there is no way reading a 128 or 256 bit vector can fault if just reading the first lane would not fault).
This is extremely processor-dependent and you should not be writing C if you’re relying on this.
No, it's not.
> you should not be writing C if you’re relying on this.
Luckily you are in no position to tell anyone what they should or shouldn't do.
Or you enable more strict build settings and BAM! You have to go back and deal with all the places your code allows you to write off the end of a buffer because you just didn't give a damn before.