(This bug report is just one example of a category of bugs that may all revolve around one bug in the compiler. I've run into this situation in various guises. The sample code below is the smallest example of the problem I've encounted so far.)
The bug manifests when: a) a generic child package declares a subtype that is simply a rename of one of its generic formal types, (the problem doesn't show up when this is done with an ordinary library level generic, only when the generic is a child) eg. generic type a is private; package x.y is subtype b is a; end x.y; b) the child is instantiated with any type (type seems to have no affect, eg. range<>, mod<>, (<>), record, etc), eg. package x_y is x.y (a => integer); c) reference the child's public subtype in a generic formal of another generic, such as the argument type for a generic formal subroutine, eg. generic with package x_y is new x.y (<>); with procedure q (r : x_y.a); package xxx is ...; d) now try to instantiate this new generic. You will have great difficulty matching q. I've found a few tricks but it is nearly impossible. The new generic can be a separate generic (such as in the example below) or it can be a child of the child, both fail. In the example below there are three compiler errors. All three are incorrect. They are each three different ways of saying the same thing. gcc (GCC) 4.0.1 ------------------------------------------------------------------------------ cd /a/projects/geb/prolib.ada/test/ gnat compile -P test.gpr -gnatc levelx.2.ada gcc -c -gnata -gnatE -fstack-check -gnatef -gnatf -gnatm50 -gnatn -gnato -gnatU -gnatwa -gnatwe -gnatwi -gnatwj -gnatwK -gnatwl -Wuninitialized -gnatVa -pass-exit-codes -O -g -gnatc -I- -gnatA -x ada /a/projects/geb/prolib.ada/test/levelx.2.ada /a/projects/geb/prolib.ada/test/levelx.2.ada:24:51: error: no visible subprogram matches the specification for "Any_Image3" /a/projects/geb/prolib.ada/test/levelx.2.ada:25:51: error: no visible subprogram matches the specification for "Any_Image3" /a/projects/geb/prolib.ada/test/levelx.2.ada:26:47: error: no visible subprogram matches the specification for "Any_Image3" /a/projects/geb/prolib.ada/test/level1.level2.level3.1.ada:5:22: error: "Level2" not declared in "Level2" gnatmake: "/a/projects/geb/prolib.ada/test/levelx.2.ada" compilation error Process compilation exited abnormally with code 4 ------------------------------------------------------------------------------ with Level1.Level2.Level3; procedure Levelx is type Type1 is new Integer; function Image1 (X : Type1) return String renames Type1'Image; package Our2 is new Level1.Level2 (Type1, Image1); package Our3 is new Our2.Level3; generic with package Any3 is new Level1.Level2.Level3 (<>); with function Any_Image3 (X : Any3.Interfaces.Level2.Level2_Type) return String is Type1'Image; procedure Do_Something (X : Any3.Interfaces.Level2.Level2_Type); procedure Do_Something (X : Any3.Interfaces.Level2.Level2_Type) is A : String := Any3.Interfaces.Level2.Level2_Image (X); B : String := Any_Image3 (X); begin if A = B then null; end if; end Do_Something; procedure Do_W is new Do_Something (Our3, Our3.Level3_Image); procedure Do_X is new Do_Something (Our3, Our2.Level2_Image); procedure Do_Y is new Do_Something (Our3, Image1); begin null; end Levelx; ------------------------------------------------------------------------------ package Level1 is end Level1; ------------------------------------------------------------------------------ generic type Arg_Type is private; with function Arg_Image (X : Arg_Type) return String; package Level1.Level2 is subtype Level2_Type is Arg_Type; function Level2_Image (X : Level2_Type) return String renames Arg_Image; package Rename is subtype Our_Arg_Type is Arg_Type; end Rename; package Interfaces is subtype Arg_Type is Rename.Our_Arg_Type; end Interfaces; end Level1.Level2; ------------------------------------------------------------------------------ generic package Level1.Level2.Level3 is function Level3_Image (X : Level2_Type) return String renames Level2.Level2_Image; package Rename is package Our_Level2 renames Level2; end Rename; package Interfaces is package Level2 renames Rename.Our_Level2; end Interfaces; end Level1.Level2.Level3; ------------------------------------------------------------------------------ -- Summary: subtype declared in generic child fails to match actual Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: ada AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gaedba at comcast dot net GCC host triplet: i686-pc-cygwin-gcc-4.0.1 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24480