comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Elaboration in generic package
Date: Thu, 13 Apr 2017 08:19:01 +0100
Date: 2017-04-13T08:19:01+01:00	[thread overview]
Message-ID: <ly1sswbwre.fsf@pushface.org> (raw)
In-Reply-To: ocm9ng$cdd$1@franka.jacob-sparre.dk

"Randy Brukardt" <randy@rrsoftware.com> writes:

> Since Ada elaborates items linearly, the instance elaboration of
> Mystic will call reallyComplicatedFunction before Seed is elaborated
> -- meaning the body would be depending on something
> uninitialized. That's what subprogram elaboration checks are designed
> to prevent. Ergo, there must be a check in this case (regardless of
> the actual body, of course).

I tried this simple demo

   package body Mystic is
      Max : Positive;
      function reallyComplicatedFunction(x : Positive) return Table is
         Result : Table (1 .. Positive'Min (X, Max) / 2) := (others => 1);
      begin
         return Result;
      end ReallyComplicatedFunction;
   begin
      Max := 5;
   end Mystic;

and, surprise, the value of Max used is 0; no warnings, no ABE, even
with -gnatE. Bug report forthcoming.

Thanks for the analysis.

  reply	other threads:[~2017-04-13  7:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12 19:30 Elaboration in generic package Simon Wright
2017-04-12 22:29 ` Randy Brukardt
2017-04-13  7:19   ` Simon Wright [this message]
2017-04-13 15:38 ` marciant
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox