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,ea5071f634c2ea8b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.35.131 with SMTP id h3mr16032630pbj.1.1321861361812; Sun, 20 Nov 2011 23:42:41 -0800 (PST) Path: lh20ni112pbb.0!nntp.google.com!news2.google.com!postnews.google.com!g7g2000vbd.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: Generic-Package Elaboration Question / Possible GNAT Bug. Date: Sun, 20 Nov 2011 23:25:39 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <7bf9bc32-850a-40c6-9ae2-5254fe220533@f29g2000yqa.googlegroups.com> <4295dc09-43de-4557-a095-fc108359f27f@y42g2000yqh.googlegroups.com> NNTP-Posting-Host: 80.156.44.178 Mime-Version: 1.0 X-Trace: posting.google.com 1321861361 18846 127.0.0.1 (21 Nov 2011 07:42:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 21 Nov 2011 07:42:41 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g7g2000vbd.googlegroups.com; posting-host=80.156.44.178; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0,gzip(gfe) Xref: news2.google.com comp.lang.ada:14472 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-11-20T23:25:39-08:00 List-Id: On 20 Nov., 10:55, "Dmitry A. Kazakov" wrote: > > On Nov 19, 4:12=A0pm, Robert A Duff > > wrote: > >> In general, the design of Ada is that if a generic body is legal, > >> then every possible instance is legal (so the compiler need not > >> check the instances). =A0The design of C++ templates is very different > >> in this regard! > > I don't know if Ada keeps that promise for generic bodies, but it certain= ly > does not for the specifications. Generic contracts are too weak for that. > Example: > > generic > =A0 =A0type T is tagged private; > package Legal is > =A0 =A0type S is new T with null record; > =A0 =A0not overriding procedure Foo (X : in out S); > end Legal; > > This and the body would successfully compile ignoring the fact that there > might exist tagged types with a primitive operation named Foo. Note that Bob said this holds true for *bodies*, here you have a *spec* that might produce an illegal instance. For bodies, Ada always assumes the worst.