Does std::memcpy make its destination determinate?
Is this not undefined behavior
It's UB, because you're copying into the wrong type. [basic.types]2 and 3 permit byte copying, but only between objects of the same type. You copied from a long long
into an int
. That has nothing to do with the value being indeterminate. Even though you're only copying sizeof(int)
bytes, the fact that you're not copying from an actual int
means that you don't get the protection of those rules.
If you were copying into the value of the same type, then [basic.types]3 says that it's equivalent to simply assigning them. That is, a
" shall subsequently hold the same value as" b
.