This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/85089] New: std::minmax


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85089

            Bug ID: 85089
           Summary: std::minmax
           Product: gcc
           Version: 5.4.0
               URL: http://cpp.sh/72nog
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kirill.okhotnikov at gmail dot com
  Target Milestone: ---

Created attachment 43765
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43765&action=edit
Source code file and detailed compiler messages.

Very simple using of minmax produces an error.

#include <iostream>
#include <string>
#include <algorithm>

int main()
{
  std::pair<double, double> a = {2.0,1.0};
  std::cout << a.first << " " << a.second << std::endl;
  a = std::minmax(a.first, a.second);
  std::cout << a.first << " " << a.second << std::endl;
}

Expected:
2 1
1 2
Got:
2 1
1 1

The same code available here http://cpp.sh/72nog. Workaround:
a = std::minmax({a.first, a.second});

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]