[LLVMbugs] [Bug 24304] New: Segmentation fault: 11 with >= in lambda in c++11

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 29 10:42:39 PDT 2015


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

            Bug ID: 24304
           Summary: Segmentation fault: 11 with >= in lambda in c++11
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mars.lenjoy at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150729/aade0603/attachment.html>


More information about the llvm-bugs mailing list