comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Possible compiler bug with this simple program
Date: Fri, 29 Aug 2008 19:50:40 -0500
Date: 2008-08-29T19:50:40-05:00	[thread overview]
Message-ID: <g9a5k0$a33$1@jacob-sparre.dk> (raw)
In-Reply-To: 48b7a778$0$23608$4f793bc4@news.tdc.fi

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:48b7a778$0$23608$4f793bc4@news.tdc.fi...
...
> If I understand Randy's explanation correctly, it does not even help to 
> pass the index range explicitly (instead of passing just the length, as in 
> your code), because the compiler invents some index range of its own for 
> accessing the Convention C unconstrained-array parameter within the Ada 
> body of the subprogram. For this code to work, you must just know what 
> this invented index-range is, in your compiler.

That is correct. For Ada, the passed in object must have some bounds, and 
the compiler either invents them (hopefully documented somewhere), or 
preferably, rejects the representation clause in the first place. I believe 
early drafts of this AI required rejection, but there was enough concern 
with compatibility that that was weakened in the final version. In any case, 
this sort of thing is not portable in any way; you have to figure out what a 
particular compiler does in order to use it at all.

The OP should keep in mind that an appropriate bug fix for GNAT is to reject 
this example, so it's not clear to me that there is much value to pushing 
for a bug fix here. The code should be fixed to avoid unconstrained array 
parameters and results unless there is no chance that it will ever be used 
on a different Ada compiler (including a newer version of GNAT, which could 
change how this is handled).

                                          Randy.





      reply	other threads:[~2008-08-30  0:50 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
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 [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox