Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!apple!oliveb!orc!Ozona!chase From: chase@Ozona.orc.olivetti.com (David Chase) Newsgroups: comp.lang.c++ Subject: Re: automatic vs static vs heap... Message-ID: <48710@ricerca.UUCP> Date: 31 Oct 89 00:48:49 GMT References: <1989Oct26.191119.9278@polyslo.CalPoly.EDU> <48706@ricerca.UUCP> Sender: news@orc.Olivetti.Com Reply-To: chase@Ozona.UUCP (David Chase) Distribution: usa Organization: Olivetti Research California, Menlo Park, CA Lines: 35 I previously posted, but two people have bugged me on this point, so I'll clarify it: >In article <1989Oct26.191119.9278@polyslo.CalPoly.EDU> ttwang@polyslo.CalPoly.EDU (Thomas Wang) writes: >>Currently there is no portable way to tell if a variable is >>allocated as automatic, heap, static, or global. >> >>I propose that C++ be extended to support the following new operators: >> [proposal deleted]. >You can probably solve most of your (sub)problem here by getting >deeply in bed with the storage allocator. For instance, the >Boehm-Weiser conservative collector "knows" what memory it is >managing, and it is possible to tell if a pointer is "real" or not. The Boehm-Weiser collector *cannot* tell if a given 32-bit value is a pointer, and integer, or your grandmother. It will assume it is a pointer. Since it does not do compaction, this is safe. This is what "conservative" means. I thought that was pretty clear, but apparently not. The point I was trying to make was: If you present it with a 32-bit value and promise that the value is in fact a Pointer, then it can tell you whether it allocated that particular pointer, how large the addressed object is, and whether it might contain pointers (i.e., whether the atomic or composite object allocator was used to obtain it). Similar techniques can be used to determine if a pointer addresses the stack segment, the text segment, or the data segment. I believe that this solves Thomas Wang's problem. He wasn't asking "is it a pointer"; he was asking "what kind of pointer is this". David