From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1888e8caa20a2f2d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!proxad.net!134.158.69.22.MISMATCH!in2p3.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Controlled types and exception safety Date: Wed, 30 Nov 2005 18:46:41 +0100 Organization: Adalog Message-ID: <2iokmd.gtm.ln@hunter.axlog.fr> References: NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1133373669 21295 195.25.228.57 (30 Nov 2005 18:01:09 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Wed, 30 Nov 2005 18:01:09 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: fr, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:6685 Date: 2005-11-30T18:46:41+01:00 List-Id: Maciej Sobczak a �crit : > 1. X is finalized. This allows me to clean up (free) its internal data. > 2. Y is *shallow-copied* to X, so that in effect X and Y share their state. > 3. X is adjusted. This allows me to duplicate its internal structure so > that it becomes independent from Y. This is the simplistic view, which is sufficient in most cases. The truth is slightly more complicated, see 7.6(11) > I think that the inherent problem comes from the fact that the > finalization of X was forced *before* its adjustment. > The canonical C++ way is to *first* make a copy of new value (because > this is when errors might occur, so that even if they occur, there was > no change in the destination object) and *then* inject the duplicate > into the destination object, getting rid of its old state (and this is > assumed to be nothrow). This is the way it actually works in Ada, unless the compiler proves that the intermediate object can be eliminated. In your case, it cannot. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr