http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58562
Bug ID: 58562 Summary: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug? Product: gcc Version: 4.7.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: jpritikin at pobox dot com Host: x86_64-linux-gnu Target: x86_64-linux-gnu Build: x86_64-linux-gnu Objects involved in the operation: iterator "__first" @ 0x0x7fffffffa370 { type = N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIP20matrixVectorProdTermNSt9__cxx19986vectorIS3_SaIS3_EEEEENSt7__debug6vectorIS3_S7_EEEE (mutable iterator); state = dereferenceable (start-of-sequence); references sequence with type `NSt7__debug6vectorI20matrixVectorProdTermSaIS1_EEE' @ 0x0x7fffffffa370 } iterator "__last" @ 0x0x7fffffffa3a0 { type = N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIP20matrixVectorProdTermNSt9__cxx19986vectorIS3_SaIS3_EEEEENSt7__debug6vectorIS3_S7_EEEE (mutable iterator); state = dereferenceable; references sequence with type `NSt7__debug6vectorI20matrixVectorProdTermSaIS1_EEE' @ 0x0x7fffffffa3a0 } Program received signal SIGABRT, Aborted. 0x00007ffff732a037 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) where #0 0x00007ffff732a037 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 #1 0x00007ffff732d698 in __GI_abort () at abort.c:90 #2 0x00007ffff1cbf5cd in __gnu_debug::_Error_formatter::_M_error() const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007ffff1f7addd in std::sort_heap<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<matrixVectorProdTerm*, std::__cxx1998::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm> > >, std::__debug::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm> > > > (__first=..., __last=...) at /usr/include/c++/4.7/bits/stl_heap.h:468 #4 0x00007ffff1f7936f in std::partial_sort<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<matrixVectorProdTerm*, std::__cxx1998::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm> > >, std::__debug::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm> > > > (__first=..., __middle=..., __last=...) at /usr/include/c++/4.7/bits/stl_algo.h:5325 #5 0x00007ffff1f77a74 in std::__introsort_loop<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<matrixVectorProdTerm*, std::__cxx1998::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm> > >, std::__debug::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm> > >, long> ( __first=..., __last=..., __depth_limit=0) at /usr/include/c++/4.7/bits/stl_algo.h:2335 #6 0x00007ffff1f76772 in std::sort<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<matrixVectorProdTerm*, std::__cxx1998::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm> > >, std::__debug::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm> > > > (__first=..., __last=...) at /usr/include/c++/4.7/bits/stl_algo.h:5476 #7 0x00007ffff1fb9194 in buildItemParamMap (oo=0x20a72d0, fc=0x1dd8240) at omxFitFunctionBA81.cpp:211 The code at omxFitFunctionBA81.cpp:211 is: std::sort(state->hgProd.begin(), state->hgProd.end()); If I turn off -D_GLIBCXX_DEBUG then the code works fine.