This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67058] New: Segmentation fault: 11 with >= in lambda in c++11
- From: "mars.lenjoy at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 29 Jul 2015 16:31:45 +0000
- Subject: [Bug c++/67058] New: Segmentation fault: 11 with >= in lambda in c++11
- Auto-submitted: auto-generated
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
<code>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
int main() {
vector<pair<string, int>> vec2 = {
pair<string, int>("aaa", 3),
pair<string, int>("baaa", 4),
pair<string, int>("bbaaa", 5),
pair<string, int>("bbaac", 5),
pair<string, int>("bbbaaa", 6),
pair<string, int>("cccddd", 6),
pair<string, int>("ddd", 3)};
sort(vec2.begin(), vec2.end(),
[](const pair<string, int> &p1, const pair<string, int> &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;
}
</code>
$ g++ test.cpp -std=c++11
$ ./a.out