[Bug libstdc++/85089] std::minmax
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Mar 27 11:53:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85089
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
std::minmax returns a pair<const double&, const double&> which refers to the
original inputs, so you are doing this:
std::pair<double, double> a{ 2, 1 };
std::pair<const double&, const double&> a2{a.second, a.first};
a = a2;
which is equivalent to:
a.first = a.second;
a.second = a.first;
Obviously this can't preserve both original values.
More information about the Gcc-bugs
mailing list