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 libstdc++/58358] New: search_n has a Complexxity violation for random access iterator


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58358

            Bug ID: 58358
           Summary: search_n has a Complexxity violation for random access
                    iterator
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kariya_mitsuru at hotmail dot com

Following code should print less than or equal to 11, but it prints 20.

#include <algorithm>
#include <vector>
#include <iostream>

int main()
{
  std::vector<int> a{2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
  int count = 0;
  std::search_n(a.begin(), a.end(), 10, 1, [&count](int t, int u){ ++count;
return t == u; });
  std::cout << count << std::endl;
}


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