2 ms·
enjoy: https://gcc.godbolt.org/z/7Pn8eqhdK https://gcc.godbolt.org/z/7Pn8eqhdK that's latest GCC, at -O3
by jcelerier 5y ago
enjoy: https://gcc.godbolt.org/z/7Pn8eqhdK https://gcc.godbolt.org/z/7Pn8eqhdK
that's latest GCC, at -O3
- moonchild 5y agoClang does generate good code https://gcc.godbolt.org/z/z781r7Phh https://gcc.godbolt.org/z/z781r7Phh But yes, sadly I think it's still generally advisable to avoid returning large structs by value. Note that this has nothing to do with RVO; as I understand it, RVO is about eliding copy constructors, not actual memory copies, and c has no copy constructors and so gets 'RVO' in all cases.