This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] libstdc++/34636
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 01 Jan 2008 17:48:53 +0100
- Subject: [v3] libstdc++/34636
Hi,
tested x86_64-linux, make check, make check-parallel, committed to mainline.
Paolo.
//////////////////
2008-01-01 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/34636
* include/parallel/algobase.h (lexicographical_compare_switch(...,
random_access_iterator_tag, random_access_iterator_tag)): Careful
with undereferenceable iterators.
* testsuite/25_algorithms/sort/34636.cc: New.
Index: include/parallel/algobase.h
===================================================================
--- include/parallel/algobase.h (revision 131244)
+++ include/parallel/algobase.h (working copy)
@@ -215,13 +215,7 @@
random_access_iterator_tag(),
random_access_iterator_tag());
- // Less because shorter.
- const bool lbs = mm.first == end1;
-
- // Less because differing elements less.
- const bool lbdel = pred(*mm.first, *mm.second);
-
- return lbs || lbdel;
+ return (mm.first == end1) || bool(pred(*mm.first, *mm.second));
}
else
{
@@ -231,13 +225,7 @@
random_access_iterator_tag(),
random_access_iterator_tag());
- // Less because shorter.
- const bool lbs = mm.first != end2;
-
- // Less because differing element less.
- const bool lbdel = pred(*mm.second, *mm.first);
-
- return lbs && lbdel;
+ return (mm.first != end2) && bool(pred(*mm.second, *mm.first));
}
}
else
Index: testsuite/25_algorithms/sort/34636.cc
===================================================================
--- testsuite/25_algorithms/sort/34636.cc (revision 0)
+++ testsuite/25_algorithms/sort/34636.cc (revision 0)
@@ -0,0 +1,33 @@
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <vector>
+#include <algorithm>
+
+// libstdc++/34636
+void test01()
+{
+ std::vector<std::vector<int> > v(2);
+ std::sort(v.begin(), v.end());
+}
+
+int main()
+{
+ test01();
+ return 0;
+}