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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:ad4:4a88:: with SMTP id h8mr27792554qvx.145.1570460591225; Mon, 07 Oct 2019 08:03:11 -0700 (PDT) X-Received: by 2002:aca:4e87:: with SMTP id c129mr18731708oib.7.1570460590837; Mon, 07 Oct 2019 08:03:10 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!o24no5399039qtl.0!news-out.google.com!q23ni277qtl.1!nntp.google.com!o24no5399030qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 7 Oct 2019 08:03:10 -0700 (PDT) In-Reply-To: <665a8b5e-533e-4df6-a1c1-7a4c257ea277@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.77.182.20; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.77.182.20 References: <1c12f540-00b8-4be8-bfc6-13ad31d9916c@googlegroups.com> <96d5218a-2714-40dd-988d-10c7d27a96a2@googlegroups.com> <665a8b5e-533e-4df6-a1c1-7a4c257ea277@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <50fceebb-c48e-4b38-b0f5-2318672a70c1@googlegroups.com> Subject: Re: GNAT: no visible subprogram matches the specification for "Put" From: Stephen Leake Injection-Date: Mon, 07 Oct 2019 15:03:11 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57255 Date: 2019-10-07T08:03:10-07:00 List-Id: On Sunday, October 6, 2019 at 4:45:22 AM UTC-7, marc...@earthlink.net wrote= : > I think that both are: both the one that can be passed a string and the o= ne that=20 > can be passed an integer. I thing that the "test signature" procedure at= least=20 > shows that the string one and the put_line one should be visible because = it > runs as expected and the string one is the one that GNAT is complaining a= bout. > I am thinking that GNAT's compilation - and my subsequent running - of th= e > Signature test program would imply that? Do you agree? To be precise, this works as expected: $ gnatchop marc.ada # produces individual files from above code $ gnatmake signature_package_instance_test $ ./signature_package_instance_test Direct Instance Put_Line("string") Direct Instance Put ("string") However, this gives a compiler error: $ gnatmake signature_package_reexport_instance gcc -c signature_package_reexport_instance.ads signature_package_reexport_instance.ads:6:01: instantiation error at signat= ure_package_reexport_generic.ads:15 signature_package_reexport_instance.ads:6:01: no visible subprogram matches= the specification for "Put" gnatmake: "signature_package_reexport_instance.ads" compilation error signature_package_reexport_generic.ads:15 is: procedure Put (X: in String) renames Instance. Put; -- instantiation erro= r "Instance.Put" is the name of a generic parameter of "Signature_Package_Gen= eric". The visibility of generic formal parameters outside the generic body is pro= blematic in GNAT. LRM 8.2 (8) says: =20 * The visible part of a generic unit includes the generic_formal_part. ... So your code should work. However, I've often had problems referring to the= m from outside the generic, and the problems seem to change with each versi= on of GNAT. Note that this is not an intended use of the generic formal par= ameters, but it is sometimes useful (if it works). So I agree this is (probably) a compiler bug. The fact that signature_package_instance compiles is not relevant; it is no= t using the name of a generic formal parameter from outside the generic; it= is only referring to them in the body of the generic, which is where they = are intended to be used. One workaround is to put a rename declaration in the generic package: package Signature_Package_Generic is procedure Put_Param (X : in String) renames Put; end; then use it in Signature_Package_Reexport_Generic: procedure Put (X : in String) renames Instance. Put_Param; This compiles.