Patchwork [Ada] Move must clear Source following assignment to Target

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 29, 2011, 2:21 p.m.
Message ID <20110829142149.GA29860@adacore.com>
Download mbox | patch
Permalink /patch/112066/
State New
Headers show

Comments

Arnaud Charlet - Aug. 29, 2011, 2:21 p.m.
The semantics of operation Move for the bounded forms must match the semantics
of the unbounded forms. The post-condition is defined (for all containers) such
that when Move completes, the Source container is empty. The fix is to clear
the Source container after its elements have been assigned to Target.

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

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

	* a-cbhama.ads, a-cbhase.ads (Move): Clear Source following assignment
	to Target.

Patch

Index: a-cbhama.adb
===================================================================
--- a-cbhama.adb	(revision 178242)
+++ a-cbhama.adb	(working copy)
@@ -728,7 +728,8 @@ 
            "attempt to tamper with cursors (container is busy)";
       end if;
 
-      Assign (Target => Target, Source => Source);
+      Target.Assign (Source);
+      Source.Clear;
    end Move;
 
    ----------
Index: a-cbhase.adb
===================================================================
--- a-cbhase.adb	(revision 178155)
+++ a-cbhase.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- --
@@ -925,7 +925,8 @@ 
            "attempt to tamper with cursors (container is busy)";
       end if;
 
-      Assign (Target => Target, Source => Source);
+      Target.Assign (Source);
+      Source.Clear;
    end Move;
 
    ----------