Nov. 10, 2022
12:29 a.m.
On 11/9/22 15:34, Guy Harris via tz wrote:
Does the C specification allow for a C implementation on a hypothetical load-store architecture machine in which:
a byte is 8 bits plus an "initialized bit";
the "uninitialize" instruction has a memory-location operand, and clears the initialized bit;
a store instruction set the initialized bit on all bytes to which it stores;
a load instruction traps if any of the bytes from which it's loading doesn't have the initialized bit set?
No, not if memcpy is implemented via load+store. The C standard says memcpy is supposed to work even if its source bytes are uninitialized. (This was news to me until today, and I'm not a fan of this part of the standard.)