diff mbox

[Ada] merge operation should always clear source

Message ID 20110803074601.GA9487@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Aug. 3, 2011, 7:46 a.m. UTC
The purpose of the Merge operation is to move elements from
a sorted vector (the source) to another sorted vector (the target).
Following the merge, the source container should be empty.  There
was an execution path (when the target was initially empty) in which
the elements of the source were merely copied onto the target,
without also removing the elements from the source.  The fix was
to use the Move operation, instead of Assign, when merging elements
from source onto an emtpy target.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-03  Matthew Heaney  <heaney@adacore.com>

	* a-cobove.adb (Merge): Move source onto target, instead of using Assign
diff mbox

Patch

Index: a-cobove.adb
===================================================================
--- a-cobove.adb	(revision 176998)
+++ a-cobove.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2004-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 2004-2011, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -762,7 +762,7 @@ 
 
       begin
          if Target.Is_Empty then
-            Target.Assign (Source);
+            Move (Target => Target, Source => Source);
             return;
          end if;