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 Path: g2news1.google.com!postnews.google.com!p31g2000prf.googlegroups.com!not-for-mail From: Jerry Newsgroups: comp.lang.ada Subject: Re: Possible compiler bug with this simple program Date: Mon, 1 Sep 2008 04:19:40 -0700 (PDT) Organization: http://groups.google.com Message-ID: <903354c9-7780-4843-a5a3-dd2c40903d40@p31g2000prf.googlegroups.com> 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> NNTP-Posting-Host: 75.171.37.202 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1220267980 5360 127.0.0.1 (1 Sep 2008 11:19:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 1 Sep 2008 11:19:40 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p31g2000prf.googlegroups.com; posting-host=75.171.37.202; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US) AppleWebKit/525.18 (KHTML, like Gecko, Safari/525.20) OmniWeb/v622.1.0.104464,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1852 Date: 2008-09-01T04:19:40-07:00 List-Id: On Aug 29, 9:47=A0pm, Jerry wrote: > On Aug 29, 6:00=A0pm, "Randy Brukardt" wrote: > > "Jerry" 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 A= da > > compilers (note that the wording specifically excludes unconstrained > > parameters for pragma Import). > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0Randy. > > 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) :=3D 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 =3D> C, Entity =3D> 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 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 =3D 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