This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/34236] New: nth_element failure: infinite loop or segmentation fault
- From: "florent dot balestrieri at ofidea dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Nov 2007 13:47:27 -0000
- Subject: [Bug libstdc++/34236] New: nth_element failure: infinite loop or segmentation fault
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
When given certain input and certain comparator, nth_element
enters in a loop or crash the program. The problem didn't
appear when using less<double>. With the comparator:
not2<less<double> >
it failed with an array of {1,1,1,1,2,3,4}
worked with an array of {1,1,1,1,2,3,4,5}
failed again with {1,1,1,1,2,2,2,3}
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
command line: g++ bug_nth_element.cpp && a.out
content of bug_nth_element follows:
<<EOF
#include <vector>
#include <iterator>
#include <iostream>
int main() {
using namespace std;
vector<double> a;
// fill_n (back_inserter(a), 4, 1.0); // infinite loop
fill_n (back_inserter(a), 4, 0.0); // segmentation fault
nth_element (a.begin(), a.begin(), a.end(), not2(less<double>()));
copy (a.begin(), a.end(), ostream_iterator<double>(cout, "\n"));
}
EOF
--
Summary: nth_element failure: infinite loop or segmentation fault
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: florent dot balestrieri at ofidea dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34236