From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f9c25380ec58962 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.75.170 with SMTP id d10mr3605569pbw.6.1326557594398; Sat, 14 Jan 2012 08:13:14 -0800 (PST) Path: lh20ni181669pbb.0!nntp.google.com!news2.google.com!eweka.nl!lightspeed.eweka.nl!feeder.erje.net!news2.arglkargh.de!news.musoftware.de!wum.musoftware.de!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 14 Jan 2012 10:13:13 -0600 User-Agent: NewsTap/3.5.1 (iPad) From: Martin Dowie Newsgroups: comp.lang.ada Mime-Version: 1.0 Message-ID: <2125280501348249894.650394martin-re.mo.ve.thedowies.com@news.btinternet.com> Subject: Re: Elaboration circularity with generics References: <583b1bfe-95bd-4669-b16b-c733c81e8f88@w4g2000vbc.googlegroups.com> Date: Sat, 14 Jan 2012 10:13:13 -0600 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-t44ixqNdcz/JCufLbdMtxl919i7eh8V5RePlx3EjYU/IhjEC2++fDjxGmDdY0pYzEcXEM9pF27bTvYk!v3NlzYH9w157ITpu3p+3u32PZw/DH07/801W2FD7a0ad4u8nv4d1TIes/z+h4YD2WNEhjrr1mF9H!drWG/sANEsMsiQuQk5Uv1+bgxZ0ffT6iH3LC8Khkm/vp4aU= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3584 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2012-01-14T10:13:13-06:00 List-Id: Maciej Sobczak wrote: > Consider: > > -- p.ads: > package P is > procedure Proc; > end P; > > -- p.adb: > with P.Q; > package body P is > package P_Int is new P.Q (T => Integer); > > procedure Proc is > begin > P_Int.Proc; > end Proc; > end P; > > -- p-q.ads: > generic > type T is private; > package P.Q is > procedure Proc; > end P.Q; > > -- p-q.adb: > package body P.Q is > procedure Proc is > begin > null; > end Proc; > end P.Q; > > -- test.adb: > with P; > > procedure Test is > begin > null; > end Test; > > The idea is that P.Q is a child, helper unit for P and P.Q is used in > the body of P. > Ideally it should be a private child, but these cannot be generic > (why?). > > Forget the Proc procedures, they do not contribute to the actual > problem, but where needed to have meaningful source units. > The problem above is: > > $ gnatmake test > gcc -c test.adb > gcc -c p.adb > gcc -c p-q.adb > gnatbind -x test.ali > error: elaboration circularity detected > info: "p (body)" must be elaborated before "p (body)" > info: reason: implicit Elaborate_All in unit "p (body)" > info: recompile "p (body)" with -gnatwl for full details > info: "p (body)" > info: must be elaborated along with its spec: > info: "p (spec)" > info: which is withed by: > info: "p.q (spec)" > info: which is withed by: > info: "p (body)" > > gnatmake: *** bind failed. > > Why this circular dependency? It does not exist if P.Q is not generic. > My initial version of P.Q was a regular package and I have found this > problem after turning it into a generic package. > > A simple workaround is to make P_Q instead of P.Q, but I would like > understand where the circularity comes from. The -gnatwl option says > that some Elaborate_All is introduced at the instantiation of P.Q, but > I see no reason for circularity there. > > -- > Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com I think a better way is to make the instantiation another child, e.g. package P.Q.Integers is new P.Q (Integer); pragma Preelaborate (P.Q.Integers); Then it is available to other packages that may need it too. -- Martin -- -- Sent from my iPad