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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fbb30b3a572ba6d0 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: Finalization and Self Assignment Date: 2000/02/29 Message-ID: #1/1 X-Deja-AN: 591421154 Sender: bobduff@world.std.com (Robert A Duff) References: Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 2000-02-29T00:00:00+00:00 List-Id: "Frank J. Lhota" writes: > - For an assignment_statement that assigns to an object the value of that > same object, the implementation need not do anything. If the implementation doesn't take advantage of the above permission, then it has to use an intermediate temporary variable, so the problem you're worried about can't happen. I don't have my RM in front of me, but I'm sure that's what it says. > ObjectAda as well as some (all?) versions of GNAT take advantage of this > permission. I would recommend that this permission be promoted to a > requirement. In other words, we should require that the compiler NOT do the > Finalize / Adjust calls when an object is assigned to itself. The issue here > is not so much efficiency as it is correctness. If we simply eliminate the > Finalize / Adjust calls from self assignments, these problems go away. In fact it's probably easier to implement that way (do nothing), even though it requires a run-time check in general to detect the self-assignment case. Now think about array assignment, where they arrays could be overlapping slices -- you don't know at compile time that they overlap, or even that they are slices. The RM allows various implementation strategies here, too. - Bob