Bug 67058 - Segmentation fault: 11 with >= in lambda in c++11
Summary: Segmentation fault: 11 with >= in lambda in c++11
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-29 16:31 UTC by Lenjoy
Modified: 2015-07-29 17:46 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lenjoy 2015-07-29 16:31:45 UTC
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
Comment 1 Markus Trippelsdorf 2015-07-29 16:35:37 UTC
This is an LLVM bug.
Comment 2 Lenjoy 2015-07-29 17:46:03 UTC
(In reply to Markus Trippelsdorf from comment #1)
> This is an LLVM bug.

okay, filed https://llvm.org/bugs/show_bug.cgi?id=24304