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 From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Possible compiler bug with this simple program Date: Thu, 28 Aug 2008 16:01:35 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1edc3682-855f-405b-8348-72b423377b1a@i20g2000prf.googlegroups.com> <48b65b3b$0$25384$4f793bc4@news.tdc.fi> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1219957336 18494 69.95.181.76 (28 Aug 2008 21:02:16 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 28 Aug 2008 21:02:16 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 Path: g2news1.google.com!news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!feed.ac-versailles.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail Xref: g2news1.google.com comp.lang.ada:1812 Date: 2008-08-28T16:01:35-05:00 List-Id: "Niklas Holsti" wrote in message news:48b65b3b$0$25384$4f793bc4@news.tdc.fi... ... > In fact, when an Ada subprogram has an unconstrained array parameter with > Convention C, it seems to me that the subprogram's body cannot make any > use of individual elements of the array, because it doesn't know the index > range, so the compiler should reject any indexing of such an array > parameter, as well as any attempt to pass it on as a Convention Ada > parameter. This is the subject of AI05-0002-1. (It was carried over from the Ada 95.) [Now, I have to go look this one up because I don't remember anything about what we decided...] Ah, yes: "We do not require support for C convention interfacing pragmas for unconstrained array objects, unconstrained array function results, and most unconstrained array parameters." In particular, "An implementation need not support ... an Export or Convention pragma applied to a subprogram which has a parameter of an unconstrained array subtype;". The wording goes on to include unconstrained array objects and function results as well. Note that an implementation *can* support this if it wants; some implementations do implement this with various meanings (Tucker reported that their compiler gives the array maximum bounds) and it was thought to be bad to break user programs that depend on such behaviors. But if it does support it, it ought to do something sensible (raising random exceptions doesn't count). (Also note that it is required to support pragma Import in this case, as C doesn't care about the bounds and they can just be dropped.) > Conclusion: Your program tries to do something that cannot possibly work, > but the compiler should have told you so. Well, not necessarily (see Tucker's implementation, for instance). But either it should do something defined *or* reject it at compile-time. (Janus/Ada would have rejected the Convention pragma.) In any case, it is not required to support this in any useful way, and, as it is not portable, it should be avoided. Randy.