This question might make no sense, but I'll ask anyway with an example. Does this code exhibit undefined behaviour?
int main() {
int a, b; // uninitialised
memcpy(&a, &b, sizeof(int));
}
I would usually say yes, because causing an lvalue-to-rvalue conversion of an uninitialised object is UB, something which must be done to copy the bytes of b
to a
.
However, memcpy
may or may not be implemented in C++. If memcpy
is written in assembly for example, then there are no such rules. Do programs that do things that would normally cause undefined behaviour still cause it if they outsource the offending operations to other languages with dissimilar rules?