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,e5a3abec221df39 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Possible compiler bug with this simple program References: <1edc3682-855f-405b-8348-72b423377b1a@i20g2000prf.googlegroups.com> <48b65b3b$0$25384$4f793bc4@news.tdc.fi> <97b1150b-cb8f-4972-b594-2ae59af84147@x16g2000prn.googlegroups.com> <8c8e5e62-16e1-4442-a6e9-f4e63fbed7a8@a8g2000prf.googlegroups.com> <903354c9-7780-4843-a5a3-dd2c40903d40@p31g2000prf.googlegroups.com> <2da4989c-4c97-43e9-8102-ba99389fdea9@v16g2000prc.googlegroups.com> <0494a60a-a452-436b-86f9-844b398aab4f@b38g2000prf.googlegroups.com> <5ca524f3-0fde-4c3b-b1a0-fe2281180ef3@k36g2000pri.googlegroups.com> <48BF3A77.3070307@spam.acm.org> <92e309c9-57d7-4a0b-8620-3320158ac0c3@a1g2000hsb.googlegroups.com> In-Reply-To: <92e309c9-57d7-4a0b-8620-3320158ac0c3@a1g2000hsb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1220634596 12.201.97.213 (Fri, 05 Sep 2008 17:09:56 GMT) NNTP-Posting-Date: Fri, 05 Sep 2008 17:09:56 GMT Organization: AT&T ASP.att.net Date: Fri, 05 Sep 2008 17:09:56 GMT Xref: g2news1.google.com comp.lang.ada:1952 Date: 2008-09-05T17:09:56+00:00 List-Id: Ludovic Brenta wrote: > > I know using System.Address may seem unholy at first sight but this > implementation is explicit about what it does -- dangerous things with > an address received from the unsafe "external world" outside the > control of the compiler. > > Comments? There's no guarantee that a C pointer and Ada's System.Address are the same thing. Of course, to be safe, you shouldn't use Integer, Long_Float, or any other type not declared in Interfaces.C and its children, or otherwise declared convention C. So really this should be something like type Double_Ptr is access all Interfaces.C.Double; pragma Convention (C, Double_Ptr); procedure Ada_Callback (Length : Interfaces.C.Int; First_Component : Double_Ptr); pragma Convention (C, Ada_Callback); And then mess with pointer arithmetic (: But a constrained array type is just as safe: type C_List is array (Interfaces.C.Int range 0 .. Interfaces.C.Int'Last) of aliased Interfaces.C.Double; pragma Convention (C, C_List); procedure Ada_Callback (Length : Interfaces.C.Int; List : C_List); pragma Convention (C, Ada_Callback); And much easier to use. -- Jeff Carter "You me on the head hitted." Never Give a Sucker an Even Break 108