From: Jerry <lanceboyle@qwest.net>
Subject: Re: Possible compiler bug with this simple program
Date: Mon, 1 Sep 2008 04:19:40 -0700 (PDT)
Date: 2008-09-01T04:19:40-07:00 [thread overview]
Message-ID: <903354c9-7780-4843-a5a3-dd2c40903d40@p31g2000prf.googlegroups.com> (raw)
In-Reply-To: 8c8e5e62-16e1-4442-a6e9-f4e63fbed7a8@a8g2000prf.googlegroups.com
On Aug 29, 9:47 pm, Jerry <lancebo...@qwest.net> wrote:
> On Aug 29, 6:00 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> > "Jerry" <lancebo...@qwest.net> wrote in message
>
> > >FWIW, in the _real_ application that I am working on, plmap is written
> > >in C (and accessed from my binding by an Import).
>
> > Interestingly, that's completely different. That *should* work on all Ada
> > compilers (note that the wording specifically excludes unconstrained
> > parameters for pragma Import).
<snip>
> > Randy.
>
> I'll see if I can make another example where plmap is a simple program
> in C that is Import-ed and see if it bombs on a 64-bit computer.
>
> Jerry
I've changed the simple example so that plmap is implemented in C.
The results are the same as with the all-Ada version: It runs OK on my
OS X 10.4.11 machine, PPC, Ada 4.3, but my colleague reports that it
crashes on his 64-bit machine which I believe is still the 64-bit
Intel Duo running Debian lenny and GNAT 4.3.1-2. The crash looks the
same as before:
raised STORAGE_ERROR : stack overflow (or erroneous memory access)
The example as either a zip or tarball which includes the very short
code files and a three-line bash script can be downloaded from my site
here:
http://public.me.com/oscarruitt
or directly here:
http://public.me.com/oscarruitt/simple_test_case_with_c.zip
http://idisk.mac.com/oscarruitt-Public/simple_test_case_with_c.zip
(Let me know if these don't work.)
And here is the code directly:
-- x19a_temp.adb
with
type_declaration,
Ada.Text_IO;
use
type_declaration,
Ada.Text_IO;
procedure x19a_temp is
procedure mapform19(n : Integer; x : in out Real_Vector);
pragma Convention(C, mapform19);
procedure mapform19(n : Integer; x : in out Real_Vector) is
begin
for i in 0 .. n - 1 loop
x(i) := Long_Float(i);
Put_Line(Long_Float'image(x(i)));
end loop;
end mapform19;
begin
plmap(mapform19'Unrestricted_Access);
end x19a_temp;
-- type_declaration.ads
package type_declaration is
type Real_Vector is array (Integer range <>) of Long_Float;
type Map_Form_Function_Pointer_Type is access
procedure (Length_Of_x : Integer; x : in out Real_Vector);
pragma Convention(Convention => C, Entity =>
Map_Form_Function_Pointer_Type);
procedure plmap(Map_Form_Function_Pointer :
Map_Form_Function_Pointer_Type);
pragma Import(C, plmap, "plmap");
end type_declaration;
/* plplot.h */
#include <stdint.h>
void plmap( void (*mapform)(int32_t, double *));
/* plmap.c */
#include "plplot.h"
void plmap( void (*mapform)(int32_t, double *) )
{
int32_t n;
double xx[10];
n = 10;
(*mapform)(n, xx);
}
# Compile and run with these lines:
gcc -c plmap.c
gnatmake x19a_temp.adb -largs plmap.o
./x19a_temp
Thanks once again.
Jerry
next prev parent reply other threads:[~2008-09-01 11:19 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 [this message]
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
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