From: Leo Brewin <leo.brewin@internode.on.net>
Subject: Is this a bug in Ada.Numerics?
Date: Sat, 20 Oct 2012 17:37:36 -0700 (PDT)
Date: 2012-10-20T17:37:36-07:00 [thread overview]
Message-ID: <8391f2d1-b4c7-4b12-bc16-1419a1aa9739@googlegroups.com> (raw)
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
next reply other threads:[~2012-10-21 0:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-21 0:37 Leo Brewin [this message]
2012-10-21 1:54 ` Is this a bug in Ada.Numerics? Yannick Duchêne (Hibou57)
2012-10-21 2:39 ` Leo Brewin
2012-10-21 1:55 ` Ludovic Brenta
2012-10-21 2:32 ` Leo Brewin
2012-10-21 3:39 ` Ludovic Brenta
2012-10-21 3:54 ` Leo Brewin
2012-10-21 8:59 ` Georg Bauhaus
2012-10-23 15:48 ` Vincent Marciante
2012-10-23 22:52 ` Leo Brewin
2012-10-23 23:09 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox