Re:A comprehensive guide to 50 years of evolution of strict ...
by tpush on Friday November 26, 2021 @04:29AM
(#29348693)
Do you have an example of that where C++ struct returns are optimized but not C ones?
[ Parent
| on HN ]
Re:A comprehensive guide to 50 years of evolution of strict ...
by jcelerier on Friday November 26, 2021 @06:57AM
(#29349443)
enjoy: https://gcc.godbolt.org/z/7Pn8eqhdK
that's latest GCC, at -O3
Re:A comprehensive guide to 50 years of evolution of strict ...
by moonchild on Saturday November 27, 2021 @03:12AM
(#29358502)
Clang does generate good code 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.