This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix Ada bootstrap failure


On Fri, 2 Sep 2011, Robert Dewar wrote:

> 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

The bootstrap failure showed NULL pointer dereferences (which
probably easily points to the affected part of the RTS).

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]