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,fbb2432d0a728c1b X-Google-Attributes: gid103376,public From: dewarr@my-dejanews.com Subject: Re: help with pointerproblem. Date: 1998/09/12 Message-ID: <6tdhnq$3ig$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 390387291 References: <35f7f673.0@newsfeed.uu.se> <35f88e65.0@news.pacifier.com> <6ta4lf$e0b1@onews.collins.rockwell.com> X-Http-User-Agent: Mozilla/2.02 (OS/2; I) X-Http-Proxy: 1.0 x8.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Sat Sep 12 10:17:35 1998 GMT Newsgroups: comp.lang.ada Date: 1998-09-12T00:00:00+00:00 List-Id: In article <6ta4lf$e0b1@onews.collins.rockwell.com>, No@Junk.Mail wrote: > > Since VertexArray is unconstrained, there will have to be a descriptor > someplace. It's likely the pointer points to the descriptor instead > of the data. I'd prefer to take the 'address of element zero of the > array. Seems to me that's more likely to work across nearly all > platforms. Like this: > > return GLPointer (ToGlPointerPackage.To_Pointer (vPtr(0)'Address)); > This is incorrect, it is in fact rather unlikely that the pointer points to the descriptor. The two more common ways of implementing unconstrained pointers are as follows: 1. Fat pointers, as used by GNAT by default. Here the pointer is two pointers, one to the data and one to the descriptor. 2. Thin pointers, as used by GNAT if a size clause is used to force single pointer length. Here the pointer is to the data, but the bounds are just "behind" the data. Many other Ada compilers have used this technique. It is actually quite rare to point to a descriptor (I think that the RR compiler may have done this at least at one point). Even if the pointer *does* point to the descriptor, you still should expect that arr'address is the address of the first element on an Ada 95 compiler because of RM 13.3(14): For an array X, X'Address should point at the first component of the array, and not at the array bounds. This is implementation advice rather than a requirement, but a compiler is supposed to follow implementation advice unless there is a good reason not to, and it is hard to imagine that this obviously good advice would not be followed. Moreover, if your compiler does not follow it, then this MUST be documented, this is a requirement of annex M. If you have an Ada 95 compiler which does not follow this implementation advice, I would report it as a bug to your vendor. Nevertheless, the caution of using the address of the first element is a reasonably one, which might possibly help you out with a recalcitrant vendor who for some reason refused to follow this implementation advice. Most certainly GNAT DOES follow this advice, and every other Ada 95 compiler which I am aware of also follows this advice. Robert Dewar Ada Core Technologies -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum