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,4608b6f4718e680f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.241.7 with SMTP id we7mr4762359pbc.4.1336611491139; Wed, 09 May 2012 17:58:11 -0700 (PDT) MIME-Version: 1.0 Path: pr3ni8079pbb.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.tornevall.net!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Problem in "X (1).Re := X (1).Re + 1" Date: Wed, 9 May 2012 19:58:04 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <13177506.38.1336222539273.JavaMail.geo-discussion-forums@pbtg6> <21452734.731.1336405064187.JavaMail.geo-discussion-forums@ynbv35> <5749033.1275.1336416838264.JavaMail.geo-discussion-forums@pbchd7> <10294366.7.1336426132700.JavaMail.geo-discussion-forums@yngg23> <5209872.2691.1336497260879.JavaMail.geo-discussion-forums@ynlq12> <30097103.0.1336555778034.JavaMail.geo-discussion-forums@pbcow8> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1336611489 4325 69.95.181.76 (10 May 2012 00:58:09 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 10 May 2012 00:58:09 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-05-09T19:58:04-05:00 List-Id: "ytomino" wrote in message news:30097103.0.1336555778034.JavaMail.geo-discussion-forums@pbcow8... ... > I had not made an issue of deallocation, too. > At first, I wanted to make calling Reference earlier than calling > Constant_Reference in same statement. > But it's a kind of "dangling pointer". > Real problem is old access value designated to the shared area still alive > after copy-on-write. > (I'm so thankful to Adam.) This reminds me of something I forgot: The beauty of Constant_Reference/Reference in the standard containers is that there cannot be a dangling pointer (assuming no Unchecked programming is involved). These are tampering events so long as the pointer still exists, and thus is it impossible to modify the container (attempts to do so will raise Program_Error). So the act of assigning a "Constant_Reference" as Adam did is to "lock" the container from [most] modification for a long time. That might be a problem for the program, but it can't cause the container to become corrupt. (Iterators also use the tampering solution to prevent problems, but they use a weaker form.) Of course, that might not be true for a user-defined container, but then you have to work out your own solution to the problem. Randy.