Re: Possible compiler bug with this simple program
- From: "Randy Brukardt" <randy@xxxxxxxxxxxxxx>
- Date: Fri, 29 Aug 2008 19:50:40 -0500
"Niklas Holsti" <niklas.holsti@xxxxxxxxxxxxxxx> wrote in message
news:48b7a778$0$23608$4f793bc4@xxxxxxxxxxxxxx
....
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.
.
- References:
- Possible compiler bug with this simple program
- From: Jerry
- Re: Possible compiler bug with this simple program
- From: Jerry
- Re: Possible compiler bug with this simple program
- From: Niklas Holsti
- Possible compiler bug with this simple program
- Prev by Date: Re: OpenToken
- Next by Date: Re: Possible compiler bug with this simple program
- Previous by thread: Re: Possible compiler bug with this simple program
- Next by thread: Anyone using gnat-gps 4.3~2008.08.09 in Debian unstable or Ubuntu?
- Index(es):
Relevant Pages
|