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,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,16e06ab8237bab07,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.248.34 with SMTP id yj2mr1826908pbc.2.1350779856823; Sat, 20 Oct 2012 17:37:36 -0700 (PDT) Received: by 10.68.219.198 with SMTP id pq6mr1599338pbc.0.1350779856809; Sat, 20 Oct 2012 17:37:36 -0700 (PDT) Path: s9ni23372pbb.0!nntp.google.com!kr7no6101910pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 20 Oct 2012 17:37:36 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=118.209.197.202; posting-account=l8GBMwoAAADCbqdOJSbg4dBRqkD14dJd NNTP-Posting-Host: 118.209.197.202 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8391f2d1-b4c7-4b12-bc16-1419a1aa9739@googlegroups.com> Subject: Is this a bug in Ada.Numerics? From: Leo Brewin Injection-Date: Sun, 21 Oct 2012 00:37:36 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-10-20T17:37:36-07:00 List-Id: In the course of my dabblings in Ada I've come across a curious "behaviour" that seems to me, with my limited knowledge of Ada, to be a bug. Here is a simple package spec with Ada.Numerics.Generic_Complex_Types; with Ada.Numerics.Generic_Complex_Elementary_Functions; package foo is type Real is digits 18; package Complex_Types is new Ada.Numerics.Generic_Complex_Types (Real); use foo.Complex_Types; -- subtype Complex is foo.Complex_Types.Complex; procedure bar (z : in out Complex); end foo; and the package body package body foo is package Complex_Maths is new Ada.Numerics.Generic_Complex_Elementary_Functions (Complex_Types); procedure bar (z : in out Complex) is begin z := Complex'(Re(z),0.0); end bar; end foo; As it stands this package compiles under GNAT GPL 2012. But if the "subtype" declaration in the package spec is un-commented then the compile fails with the following errors 04: instantiation error at a-ngcefu.ads:24 04: "Complex" is not visible (more references follow) 04: instantiation error at a-ngcefu.ads:24 04: non-visible declaration at foo.ads:11 04: instantiation error at a-ngcefu.ads:24 04: non-visible declaration at a-ngcoty.ads:42, instance at foo.ads:8 04: instantiation error at a-ngcefu.ads:24 04: non-visible declaration at a-ngcoty.ads:42, instance at a-ngcefu.ads:18 Is this behaviour correct? My limited understanding is that the "use foo.Complex_Types" should have made visible all types and operations on "Complex" and thus the extra "subtype" should be redundant and should not cause an error. I've tried a few variations on the above and I found that if I 1) Comment out the "Package Complex_Maths" declaration, OR 2) Create a single procedure from the above package spec/body then the code compiles happily with or without the "subtype" declaration. If anybody could explain this behaviour to me I would be very grateful. Cheers, Leo