2 ms·
Is there actually an offical list of stdlib functions compilers are "permitted" to inline - and why shouldn't they be able to do it for any such function? If th
by wizofaus 4y ago
Is there actually an offical list of stdlib functions compilers are "permitted" to inline - and why shouldn't they be able to do it for any such function? If they're statically linked I can't see how it matter, you're just saving on some machine code instructions to push arguments to the stack and pop them off again (plus the instruction pointer jumps) surely?
- flohofwoe 4y agoIt'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.