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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f9c25380ec58962,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.74.201 with SMTP id w9mr3535659pbv.0.1326553759192; Sat, 14 Jan 2012 07:09:19 -0800 (PST) Path: lh20ni181499pbb.0!nntp.google.com!news1.google.com!postnews.google.com!w4g2000vbc.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Elaboration circularity with generics Date: Sat, 14 Jan 2012 07:09:18 -0800 (PST) Organization: http://groups.google.com Message-ID: <583b1bfe-95bd-4669-b16b-c733c81e8f88@w4g2000vbc.googlegroups.com> NNTP-Posting-Host: 83.3.40.82 Mime-Version: 1.0 X-Trace: posting.google.com 1326553759 6892 127.0.0.1 (14 Jan 2012 15:09:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 14 Jan 2012 15:09:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w4g2000vbc.googlegroups.com; posting-host=83.3.40.82; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-01-14T07:09:18-08:00 List-Id: 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