3 ms·
It's not just about inlining, the compiler may decide to entirely remove memory accesses when memcpy is used to copy one struct to another, like in this case:
by flohofwoe 4y ago
It's not just about inlining, the compiler may decide to entirely remove memory accesses when memcpy is used to copy one struct to another, like in this case:
https://www.godbolt.org/z/Ezb7hh6eq https://www.godbolt.org/z/Ezb7hh6eq
...and for the same reason, AFAIK the compiler isn't required to preserve struct padding bytes either in such a case, so even though memcpy() is used for copying one struct into another in the original source code, the compiler may actually generate code which behaves differently from a straight memcpy() - but in this case I'm not 100% sure, I just wouldn't depend on it, because I've been bitten in the ass multiple times when it comes to assuming the content of padding bytes.