3 ms·
memcpy() by itself cannot violate aliasing rules. By definition, char can alias any object. Whether you can access an object that has been memcpy()'d into is a
by haberman 6y ago
memcpy() by itself cannot violate aliasing rules. By definition, char can alias any object.
Whether you can access an object that has been memcpy()'d into is a separate question. I can't find specific language about this, but I strongly suspect that the result is implementation-defined or unspecified (not undefined), unless there is a possibility of a trap representation.
- kazinator 6y agoThis remark doesn't appear to add anything to my original unedited comment, which includes the clarifying words "you can't memcpy an object to one of a different type and then access it as that type without invoking undefined behavior".