https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67058
Bug ID: 67058
Summary: Segmentation fault: 11 with >= in lambda in c++11
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mars.lenjoy at gmail dot com
Target Milestone: ---
I filed this because I assume this is not a deprecated version.
This is the current g++ in my OS X 10.9.5
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
#include
#include
#include
#include
#include
using namespace std;
int main() {
vector> vec2 = {
pair("aaa", 3),
pair("baaa", 4),
pair("bbaaa", 5),
pair("bbaac", 5),
pair("bbbaaa", 6),
pair("cccddd", 6),
pair("ddd", 3)};
sort(vec2.begin(), vec2.end(),
[](const pair &p1, const pair &p2) {
cout << p1.second << " vs " << p2.second << endl;
// No problem with ">"
// if (p1.second > p2.second) { return true; }
// Segmentation fault: 11 with ">=",
// it's related to the data in vec2.
if (p1.second >= p2.second) { return true; }
return false;
});
for (const auto &p : vec2) {
cout << p.first << ", " << p.second << endl;
}
cout << endl;
}
$ g++ test.cpp -std=c++11
$ ./a.out