From: JP Thornley <jpt@diphi.demon.co.uk>
Subject: Elaboration problem with a task
Date: Thu, 5 Jan 2006 10:04:02 +0000
Date: 2006-01-05T10:04:02+00:00 [thread overview]
Message-ID: <fwjHYACS8OvDJw3e@diphi.demon.co.uk> (raw)
I'm getting an elaboration error and I don't understand why. It seems
to be caused by having a task in a package body that calls a procedure
in a child of that package.
Various restructurings, such as moving the task to a second child
package, have failed to clear the error.
I'm using Gnat 3.15p (GPS 2.1.0 on XP Pro).
The error goes away if I replace the direct call to the procedure in
the child (Child_C1.Proc1 in the code) by an indirect call to a local
procedure in the package body that then makes the call (Parent_Proc2)
but I guess that is only hiding the problem rather than solving it.
with Parent_P;
procedure Proc_P is
begin
Parent_P.Parent_Proc1;
end Proc_P;
package Parent_P is
procedure Parent_Proc1;
private
Data1 : Integer;
end Parent_P;
with Parent_P.Child_C1;
package body Parent_P is
procedure Parent_Proc1 is
begin
null;
end Parent_Proc1;
procedure Parent_Proc2 is
begin
Child_C1.Proc1 (Data1);
end Parent_Proc2;
task Parent_T;
task body Parent_T is
begin
Child_C1.Proc1 (Data1);
end Parent_T;
end Parent_P;
package Parent_P.Child_C1 is
procedure Proc1 (P1 : in Integer);
end Parent_P.Child_C1;
package body Parent_P.Child_C1 is
procedure Proc1 (P1 : in Integer) is
begin
null;
end Proc1;
end Parent_P.Child_C1;
gnatbind -static -x proc_p.ali
error: elaboration circularity detected
info: "parent_p (body)" must be elaborated before "parent_p (body)"
info: reason: Elaborate_All probably needed in unit "parent_p
(body)"
info: recompile "parent_p (body)" with -gnatwl for full details
info: "parent_p (body)"
info: must be elaborated along with its spec:
info: "parent_p (spec)"
info: which is withed by:
info: "parent_p.child_c1 (spec)"
info: which is withed by:
info: "parent_p (body)"
gnatmake: *** bind failed.
Adding pragma Elaborate_All(Parent_P.Child_C1); to the body of Parent_P
(as suggested) produces the same error except that the pragma is now
given as the reason for the circularity.
Using -gnatwl doesn't produce any additional information.
An unexpected part of the error message is that the body of Parent_P
"must be elaborated along with its spec". Can anyone explain why this is
or otherwise suggest how to avoid the problem.
Cheers, and TIA,
Phil Thornley
--
JP Thornley
next reply other threads:[~2006-01-05 10:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-05 10:04 JP Thornley [this message]
2006-01-05 10:16 ` Elaboration problem with a task Martin Dowie
2006-01-05 11:13 ` JP Thornley
2006-01-05 14:18 ` Martin Dowie
2006-01-05 16:35 ` Pascal Obry
2006-01-05 19:34 ` Jeffrey R. Carter
2006-01-05 20:42 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox