The following code generates a segmentation fault when compiled with GCC 6.1.0. Strangely, the error is consistent, but does not happen with smaller sizes or slightly different comparison expressions. Do you guys have any idea why?
#include <vector>
#include <algorithm>
#include <iostream>
int main() {
int n = 1000;
std::vector<std::pair<double, double>> vec;
for(int i = 0; i < n; i++) {
vec.push_back(std::make_pair<double, double>((7*i)%3, (3*i)%5));
}
std::sort(vec.begin(), vec.end(), [](std::pair<double, double> const & p1, std::pair<double, double> const & p2) {return (p1.first < p2.first) || ((p1.first==p2.first)&& (p1.second <= p2.second));});
return 0;
}
Aucun commentaire:
Enregistrer un commentaire