From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29078 invoked by alias); 12 Apr 2012 21:42:43 -0000 Received: (qmail 29010 invoked by uid 22791); 12 Apr 2012 21:42:41 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Apr 2012 21:42:27 +0000 From: "jyasskin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/52822] [C++11] stable_partition destroys sequence due to inappropriate self-move-assignment Date: Thu, 12 Apr 2012 21:42:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: jyasskin at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg00911.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52822 --- Comment #10 from Jeffrey Yasskin 2012-04-12 21:42:00 UTC --- Author: jyasskin Date: Thu Apr 12 21:41:55 2012 New Revision: 186394 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186394 Log: Fix PR52822 (stable_partition move-assigns object to itself) by scanning for the first value that doesn't match the predicate before starting to rearrange values. 2012-04-03 Jeffrey Yasskin PR libstdc++/52822 * include/bits/stl_algo.h (__find_if_not): Expose in C++98 mode. (__find_if_not_n): Like __find_if_not, but works on and updates a counted range instead of a bounded range. (stable_partition): Guarantee !__pred(*__first) in call to __stable_partition_adaptive() or __inplace_stable_partition(). (__stable_partition_adaptive): Use new precondition to avoid moving/copying objects onto themselves. Guarantee new precondition to recursive calls. (__inplace_stable_partition): Use new precondition to simplify base case, remove __last parameter. Guarantee new precondition to recursive calls. * testsuite/25_algorithms/stable_partition/moveable.cc (test02): Test a sequence that starts with a value matching the predicate. * testsuite/25_algorithms/stable_partition/pr52822.cc: Test vectors, which have a destructive self-move-assignment. Added: branches/gcc-4_7-branch/libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc - copied unchanged from r186391, trunk/libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc Modified: branches/gcc-4_7-branch/ (props changed) branches/gcc-4_7-branch/libstdc++-v3/ChangeLog branches/gcc-4_7-branch/libstdc++-v3/include/bits/stl_algo.h branches/gcc-4_7-branch/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc Propchange: branches/gcc-4_7-branch/ ('svn:mergeinfo' added)