https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80874
--- Comment #1 from denis.campredon at gmail dot com --- Sorry, minmax3 should not produce the same asm, since minmax return a pair of const reference. But still the code is less than optimal. One part it is because gcc might be because gcc is not able to optimize the two functions the same way: --------------- struct pair { const int &x, y; }; pair minmax(int x) { return {x, x}; } const std::pair<const int&, const int&> minmax2(int x) { return std::minmax(x, x); } --------------