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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c50f57c0c29b391b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: memory management Date: 02 Jun 2005 13:05:21 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1131064.rs72P29t4t@yahoo.com> <1226363.QsRZW1KHie@linux1.krischik.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1117731921 24950 192.74.137.71 (2 Jun 2005 17:05:21 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 2 Jun 2005 17:05:21 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:11216 Date: 2005-06-02T13:05:21-04:00 List-Id: Thomas Maier-Komor writes: > Robert A Duff wrote: > > The same is true of pointers in C and C++ -- an implementation is free > > to implement pointers as something other than a machine address. In > > fact, if a C compiler wishes to check array bounds, it pretty much *has* > > to use fat pointers. I know of one C compiler that did just that. My > > point is that "pointer" is not synonymous with "single machine address", > > even in C. > > > > That's definetly an interesting implementation variant for the C > language. Could you tell us, which compiler did this? Has this been > documented anywhere? No, sorry, but I can't remember the name of the company or the product. I think they went out of business about 10 years ago. Their compiler was intended for testing -- detecting array indices out of bounds. Here's how to do it: allocate one word of dope before each array, to store the length of the array. Represent each C pointer as a fat pointer: pointer to the dope, and pointer to the array element. Treat non-array objects like one-element arrays. Then on each pointer dereference, check that the element pointer is between the start and end of the array. Ada compilers can do all this *much* more efficiently. Ada does not need fat pointers. GNAT uses them, but only in rare cases. - Bob