[PATCH] Fix Ada bootstrap failure

Robert Dewar dewar@adacore.com
Fri Sep 2 13:15:00 GMT 2011


On 9/2/2011 8:58 AM, Arnaud Charlet wrote:
>>> In Ada, it's quite natural to end up with a dynamically sized object of
>>> size 0. For instance, if you declare an array with a dynamic bound:
>>>
>>>     Table : Unit_Table (1 .. Last_Unit);
>>>
>>> and Last_Unit happens to be 0 at run-time
>>
>> But are we expected to read/store from the storage?
>
> No, that shouldn't happen, although you can e.g. reference Table'Address
> and expect it to be non null.

Actually I am not sure of this, I discussed this with Bob, Address
is defined as the pointing to the first storage unit allocated for
an object. Not clear what this means when the object has no storage
units. This is a gap in the RM. Bob's view is that it must return
some random valid address (what exactly *is* a valid address?)
>
>> I'd have
>> expected that alloca (0) returning NULL shouldn't break
>> anything at runtime ...
>
> Not sure exactly what failed here, probably something relatively subtle
> (perhaps related to passing this variable or a "slice" of this variable
> to another procedure).

But that wouldn't cause a dereference, however, it might cause an
explicit test that the argument was not null, and perhaps that's
what is causing the trouble.

For example, if you have something like

     type S is aliased array (1 .. N);
     type P is access all S;
     B : S;

     procedure Q is (A : not null Astring) is
     begin
        null;
     end;

     Q (B'Access);

Then there will be an explicit check that B is not null




>
> Arno



More information about the Gcc-patches mailing list