From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: Possible compiler bug with this simple program
Date: Fri, 05 Sep 2008 17:09:56 GMT
Date: 2008-09-05T17:09:56+00:00 [thread overview]
Message-ID: <EJdwk.329253$yE1.179336@attbi_s21> (raw)
In-Reply-To: <92e309c9-57d7-4a0b-8620-3320158ac0c3@a1g2000hsb.googlegroups.com>
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
next prev parent reply other threads:[~2008-09-05 17:09 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-28 7:28 Possible compiler bug with this simple program Jerry
2008-08-28 7:56 ` Ludovic Brenta
2008-08-28 21:08 ` Jerry
2008-08-29 20:39 ` Ludovic Brenta
2008-08-29 21:20 ` Jerry
2008-08-29 21:31 ` Jerry
2008-09-02 22:10 ` Santiago Urueña
2008-08-28 8:03 ` Niklas Holsti
2008-08-28 15:54 ` Adam Beneschan
2008-08-28 15:56 ` Adam Beneschan
2008-08-28 21:01 ` Randy Brukardt
2008-08-28 21:29 ` Jerry
2008-08-30 1:00 ` Randy Brukardt
2008-08-30 4:47 ` Jerry
2008-09-01 11:19 ` Jerry
2008-09-03 4:22 ` Jerry
2008-09-03 14:20 ` Adam Beneschan
2008-09-04 0:22 ` Jerry
2008-09-04 1:18 ` Adam Beneschan
2008-09-04 3:53 ` Randy Brukardt
2008-09-04 1:31 ` Jeffrey R. Carter
2008-09-04 14:35 ` Adam Beneschan
2008-09-04 14:42 ` Jacob Sparre Andersen
2008-09-06 3:03 ` Jerry
2008-09-05 8:17 ` Ludovic Brenta
2008-09-05 15:56 ` Adam Beneschan
2008-09-05 17:09 ` Jeffrey R. Carter [this message]
2008-09-04 20:49 ` Simon Wright
2008-08-28 21:16 ` Jerry
2008-08-29 7:41 ` Niklas Holsti
2008-08-30 0:50 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox