3 ms·
> What if the objects are non-NULL, but invalid (not actually allocated)? Still UB, since they're restricted pointers that must be valid to begin with.
by creshal 2y ago
> What if the objects are non-NULL, but invalid (not actually allocated)?
Still UB, since they're restricted pointers that must be valid to begin with.
- bonzini 2y agoThis is wrong. If you do p=malloc(256), p+256 is valid even though it does not point to a valid address (it might be in an unmapped page; check out ElectricFence). Rust's non-null aligned other pointer is the same, memcpy can't assume it can be dereferenced if the size is zero. The standard text in the linked paper says the same.