Re: Possible compiler bug with this simple program



"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.


.



Relevant Pages

  • Re: Current status of Ada?
    ... learning and using this great language. ... The reason why compilers maker can't make their compiler totally free ... I agree with you that most of the links you can find on Ada websites ... AdaCore has contributed a free gnat compiler to ...
    (comp.lang.ada)
  • Re: Ravenscar-compliant bounded buffer
    ... the mid 1980's most compiler are FRONT_END compilers aka ... any system build around GNAT will contain the C code that GNAT ... The XGC Ada which is based on GNAT and uses C for its Real Time ... with VAXes for data processing applications. ...
    (comp.lang.ada)
  • Re: 7E7 Flight Controls Electronics
    ... Given that people had choices and Ada ... the 800 or so programming languages in use by the DoD, ... DoD1 was expected to provide a 'language of last resort', ... need modifications to a compiler to support particular requirements, ...
    (comp.lang.ada)
  • Re: Distributed Computing in Ada
    ... no shared memory. ... Ada tasks /can/ share memory, ... The problem is that the compiler can't know which variables are shared. ... The unit of distribution ...
    (comp.lang.ada)
  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... Though I haven't done so recently, back when I used Ada, nowhere close ... This can be ameliorated in a case like GNAT, where the Ada compiler ... _every_ programming language places severe limits on expressiveness; ... Ada's exception handling is also primitive at best (exceptionally so, ...
    (comp.lang.cpp)