http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47703
Summary: [4.6 Regression] [C++0x] ICE: std::sort chokes on simple lambda function Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: erik.sandbraa...@gmail.com The following code test.cc : #include <algorithm> #include <vector> int main() { std::vector<int> vec; std::sort(vec.begin(), vec.end(), [](int& t1, int& t2) {return t1 < t2;}); return 0; } Results in: ~/c++bug$ g++ -std=c++0x test.cc -o test In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/algorithm:63:0, from test.cc:1: /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h: In function ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >, _Tp = int, _Compare = main()::<lambda(int&, int&)>]’: /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:2265:78: instantiated from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >, _Compare = main()::<lambda(int&, int&)>]’ /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:2306:62: instantiated from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >, _Size = int, _Compare = main()::<lambda(int&, int&)>]’ /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:5341:4: instantiated from ‘void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >, _Compare = main()::<lambda(int&, int&)>]’ test.cc:8:77: instantiated from here /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:2233:4: error: no match for call to ‘(main()::<lambda(int&, int&)>) (int&, const int&)’ test.cc:8:40: note: candidates are: /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:2233:4: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper Target: i686-pc-linux-gnu Configured with: ../configure -v --enable-languages=c,c++ Thread model: posix gcc version 4.6.0 20110205 (experimental) (GCC)