From: Stefan Bellon <bellon@software-erosion.org>
Subject: Re: Generic Zero Length Array
Date: Fri, 22 Feb 2008 16:22:24 +0100
Date: 2008-02-22T16:22:24+01:00 [thread overview]
Message-ID: <20080222162224.0b9e4ca8@cube.tz.axivion.com> (raw)
In-Reply-To: 9b771018-fb0b-42eb-ae00-12ee3eda69b2@p43g2000hsc.googlegroups.com
On Fr, 22 Feb, shaunpatterson@gmail.com wrote:
> if Error_Condition then
> declare
> type Result is new Element_List (Indexing.First + 1 ..
> Indexing'First);
> Result_String : Result;
> begin
> return Element_List (Result);
> end;
> end if;
>
> How do I initialize this array when I can't know what type it is or
> will be?
Funny, just yesterday I came across the code that did exactly this
in our software:
if List_Length = 0 then
if Index_Type'Base'First = Index_Type'Base'Last then
-- there seems to be no way to declare a null array
-- for a `type Index_Type is (A)`
raise Constraint_Error;
else
-- Workaround due to GNAT 6.0.2 bug (H221-018).
return (Index_Type'Base'Last ..
Index_Type'Base'Pred (Index_Type'Base'Last) => <>);
end if;
else
-- non-empty case
end if;
And previously we had
return (Index_Type'Base'Last .. Index_Type'Base'First => <>);
written, which triggered H221-018, therefore we rewrote to use 'Pred.
Greetings,
Stefan
--
Stefan Bellon
next prev parent reply other threads:[~2008-02-22 15:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-22 13:31 Generic Zero Length Array shaunpatterson
2008-02-22 13:53 ` Egil Høvik
2008-02-22 13:55 ` shaunpatterson
2008-02-22 14:11 ` Georg Bauhaus
2008-02-22 19:25 ` Randy Brukardt
2008-02-22 23:01 ` Adam Beneschan
2008-02-23 9:30 ` Dmitry A. Kazakov
2008-02-23 14:27 ` Robert A Duff
2008-02-23 16:16 ` Dmitry A. Kazakov
2008-02-25 16:41 ` Adam Beneschan
2008-02-25 19:14 ` Robert A Duff
2008-02-22 19:25 ` Randy Brukardt
2008-02-22 19:25 ` Randy Brukardt
2008-02-22 14:23 ` Stefan Lucks
2008-02-22 16:52 ` Adam Beneschan
2008-02-22 14:26 ` Robert A Duff
2008-02-22 15:22 ` Stefan Bellon [this message]
2008-02-22 23:03 ` Adam Beneschan
2008-02-23 10:19 ` Stefan Bellon
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox