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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,203a32feed9332ee,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!peer1.news.newnet.co.uk!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Generic instantiation with constrained subtype Date: Sat, 23 Aug 2008 13:59:20 +0100 Organization: Pushface Message-ID: NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1219496361 17544 62.49.19.209 (23 Aug 2008 12:59:21 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 23 Aug 2008 12:59:21 +0000 (UTC) Cancel-Lock: sha1:6v10bJx8/nbLbSLBohueM+/h6oU= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2.50 (darwin) Xref: g2news1.google.com comp.lang.ada:1779 Date: 2008-08-23T13:59:20+01:00 List-Id: I've been trying to write some test cases for the Booch Components and came up with this. The test case is written as a generic, to be instantiated with the appropriate Container type. This is fine for the definite containers (ie, ones like No_Problem below) but fails for the Bounded forms, which use the Unconstrained/Constrained technique. This is the example: ----------------------------------------------------------------------- package Instantiation_Problem is type Base is tagged null record; type No_Problem is new Base with null record; type Unconstrained (Constraint : Positive) is new Base with null record; subtype Constrained is Unconstrained (Constraint => 10); generic type T is new Base with private; package G is end G; package NP is new G (No_Problem); package F is new G (Constrained); -- ^--------------------18:24 package U is new G (Unconstrained); -- ^--------------------21:24 end Instantiation_Problem; ----------------------------------------------------------------------- and GNAT (GCC 4.3.0) says instantiation_problem.ads:18:24: constraint on actual is incompatible with formal instantiation_problem.ads:18:24: instantiation abandoned instantiation_problem.ads:21:24: actual subtype must be constrained instantiation_problem.ads:21:24: instantiation abandoned Am I going to have to rethink this? Have I used the wrong way of specifying the generic parameter? Is GNAT confused? (note, at 21:24 it's asking for a subtype, so why complain at 18:24?). Ideally I'd like it if any solution could work with Ada 95 - these are the Booch Ada 95 Components! --S