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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.147.18 with SMTP id s18mr13865527yhj.28.1384840637935; Mon, 18 Nov 2013 21:57:17 -0800 (PST) X-Received: by 10.50.30.169 with SMTP id t9mr422727igh.2.1384840637739; Mon, 18 Nov 2013 21:57:17 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!dz2no943643qab.0!news-out.google.com!9ni36578qaf.0!nntp.google.com!dz2no943637qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 18 Nov 2013 21:57:17 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=180.24.171.58; posting-account=Mi71UQoAAACnFhXo1NVxPlurinchtkIj NNTP-Posting-Host: 180.24.171.58 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Strange instantiation error with formal packages From: ytomino Injection-Date: Tue, 19 Nov 2013 05:57:17 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:17726 Date: 2013-11-18T21:57:17-08:00 List-Id: Hello. Please, consider below example: ---- 8< ---- with ada.containers.ordered_sets; -- any generic package with g1; with g2; procedure main is package charsets is new ada.containers.ordered_sets (Character); package p1 is new g1 (charsets); package p1_n is new p1.nested; package p2 is new g2 (charsets, p1, p1_n); begin null; end main; with ada.containers.ordered_sets; generic with package sets is new ada.containers.ordered_sets(<>); package g1 is generic package nested is end nested; end g1; with ada.containers.ordered_sets; with g1; generic with package sets is new ada.containers.ordered_sets(<>); -- *1 with package p1 is new g1 (sets); with package p1_n is new p1.nested; package g2 is end g2; ---- >8 ---- This is OK, able to be compiled. $ gnatmake -gnat2012 main.adb gcc -c -gnat2012 main.adb gcc -c -gnat2012 g1.ads gcc -c -gnat2012 g2.ads gnatbind -x main.ali gnatlink main.ali Then... Remove the formal package "sets" from g2: ---- 8< ---- with ada.containers.ordered_sets; with g1; with g2; procedure main is package charsets is new ada.containers.ordered_sets (Character); package p1 is new g1 (charsets); package p1_n is new p1.nested; package p2 is new g2 (p1, p1_n); -- "sets" is removed begin null; end main; -- g1 is same as first example. with g1; generic -- "sets" is removed with package p1 is new g1 (<>); -- use a box instead of "sets" with package p1_n is new p1.nested; package g2 is end g2; ---- >8 ---- This is bad. $ gnatmake -gnat2012 main.adb gcc -c -gnat2012 main.adb main.adb:8:30: actual parameter must be instance of "nested" main.adb:8:30: instantiation abandoned gnatmake: "main.adb" compilation error Why? I tried with gcc-4.8.1 and GNAT GPL 2012. Regards. -- Yuta Tomino