home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!microsoft!hexnut!jimad
- From: jimad@microsoft.com (Jim Adcock)
- Subject: Re: Garbage Collection for C++
- Message-ID: <1992Aug20.212200.16033@microsoft.com>
- Date: 20 Aug 92 21:22:00 GMT
- Organization: Microsoft Corporation
- References: <2009@appli.se> <TMB.92Aug17204854@arolla.idiap.ch> <1992Aug18.045533.7193@actrix.gen.nz>
- Lines: 18
-
- In article <1992Aug18.045533.7193@actrix.gen.nz> Bruce.Hoult@bbs.actrix.gen.nz writes:
- |In article <TMB.92Aug17204854@arolla.idiap.ch> tmb@idiap.ch writes:
- |>
- |> Incidentally, there is a widely used, simple, efficient, more general,
- |> and completely portable technique for getting the same kinds of
- |> storage savings as with the XOR trick.
- |
- |Well you can trivially subtract the pointers instead of XORing them.
- |That would be more portable in practise, although I don't think ANSI C
- |guarentees that you can subtract arbitrary pointers. but only ones to
- |elements of the same array or struct.
-
- There are Order(100,000,000) computers in the world where subtracting pointers
- not to the same array will not produce the results you desire. -- Not to imply
- XORing pointers is a good idea either! If you want to write portable
- code, start by making no assumptions equating pointers to ints. Historically,
- any code that hacks pointer bits sooner or later proves to be a stumbling
- block.
-