Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!pacbell.com!pacbell!osc!tma From: tma@osc.COM (Tim Atkins) Newsgroups: comp.lang.c++ Subject: Re: Smart pointers and stupid people (was: garbag Message-ID: <4175@osc.COM> Date: 26 Jan 91 09:03:41 GMT References: <4127@osc.COM> <3344@lupine.NCD.COM> Reply-To: tma@osc.UUCP (Tim Atkins) Distribution: comp Organization: Versant Object Technology, Menlo Park, CA Lines: 33 In article cimshop!davidm@uunet.UU.NET (David S. Masterson) writes: >X-Posting-Software: GNUS 3.12 [ NNTP-based News Reader for GNU Emacs ] > >>>>>> On 12 Jan 91 23:05:11 GMT, rfg@NCD.COM (Ron Guilmette) said: > >David> In particular, if there are temp copies of the pointers on the stack or >David> register references, who cares? > >Ron> Exactly. > >Ahhh, but (as you posted in other messages) can this be statement be >guaranteed through lexical restrictions in the language. My statement is made >from the perspective that, even if there are "dead" pointers lying around, as It is precisely the assumption of "dead" that makes object relocation such a nightmare in a an untagged environment. Most compilers and optimizers work hard at not putting pointers and other intermediate products in valuable register and less valuable stack space UNLESS they expect to reuse them in the near future. However, there is no guarantee that an operation that invalidates those stored intermediaries such as a copying GC will not occur before the reuse without the compiler being any the wiser. If it occurs then the subsequent use must be restricted not from the user but from the generated code! If there is some unknown magic for doing this outside of changing the compiler then I am not aware of it. Also, I would expect such magic to make the code decidedly less efficient if it did exist. The only other, and the traditional, option is to change these stored pointers which brings us right back to the problem of knowing a real pointer from some arbitrary data with the same bit pattern. Various semi-solutions have been proposed but I would argue that only a compiler could be expected to do the job without overburdening the user. - Tim