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,3498dd887729ed19 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Garbage Collection in Ada Date: 1996/10/19 Message-ID: #1/1 X-Deja-AN: 190577138 references: <01bbb910$f1e73f60$829d6482@joy.ericsson.se> <19961016113936528855@dialup120-4-1.swipnet.se> organization: New York University newsgroups: comp.lang.ada Date: 1996-10-19T00:00:00+00:00 List-Id: Bob Duff says "What does it mean to use virtual origins in C, given that all arrays start at zero?" Two answers. At the programmers level, the logical bounds of an array may not start at zero, but at something else, so your subscripts run from say 10..100. In this situation, the normal requirement is to subtract 10 from the subscript on each reference. However, you can at the C level use virtual origins in this situation. As has been pointed out, this is not strictly correct code, but in the absence of a conservative garbage collector running around and deleting unrefrenced blocks (:-) will in fact work on any imaginable C compiler, and certainly works on GCC. For an example of this, see Gigi coding (note incidentally that Gigi is expected to be compiled using GNU C, so if ever there was some other C compiler that did NOT accept this senmantics, it won't affect Gigi coding). The second answer is that in optimizing code, all sorts of transformations can occur, especially if you start doing high level optimization that can cause non-zero based arrays to appear as part of the transformations. This is the situation in which a compiler may end up fiddling with pointers in a way that is incompatible with a conservative GC. The use of a conservative GC system is, like the virtual origin coding in Gigi, something that probably works OK, even though it is requires some dubious fiddling (in particular the assumption that type casts from integer to pointer leave bits unchanged, something that the ANSI C specification could not require even if it wanted to). Lots of C programs depend on such ANSI-standard-dubious fiddling, so there is good company here, although it is interesting to note that the mixture of two such fiddles can sometimes go astray (as is the case with conservative GC, and manual virtual origin mucking).