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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.68.231.233 with SMTP id tj9mr897914pbc.2.1394722415668; Thu, 13 Mar 2014 07:53:35 -0700 (PDT) X-Received: by 10.50.41.100 with SMTP id e4mr54104igl.0.1394722415356; Thu, 13 Mar 2014 07:53:35 -0700 (PDT) Path: border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!news.glorb.com!ur14no6745380igb.0!news-out.google.com!gi6ni105igc.0!nntp.google.com!l13no5973907iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 13 Mar 2014 07:53:34 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3d90b1df-4d18-4097-aa26-e727defd26ba@googlegroups.com> Subject: Re: Profile mismatch? From: adambeneschan@gmail.com Injection-Date: Thu, 13 Mar 2014 14:53:35 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:185162 Date: 2014-03-13T07:53:34-07:00 List-Id: On Thursday, March 13, 2014 5:06:40 AM UTC-7, Simon Wright wrote: > Given the code below >=20 > package Profile is > type A1 is abstract tagged limited null record; > procedure P (This : not null access A1); > type A2 is abstract new A1 with null record; > procedure P (This : access A2); -- mismatch > type T1 is new A1 with null record; > procedure P (This : access T1); -- mismatch > type T2 is new A2 with null record; > procedure P (This : not null access T2); -- mismatch > type T3 is new T2 with null record; > procedure P (This : access T3); -- mismatch > end Profile; >=20 > should a compiler recognise the mismatches of the null exclusions where > indicated? >=20 > GNAT (4.8, 4.9, GPL 2013) accepts this code without comment. I've seen > very similar cases (structurally, but with many more subprograms) which > GNAT didn't accept, saying >=20 > not subtype conformant with operation inherited at line 42 > type of "This" does not match >=20 > I've not yet tried to track this down. All of the access parameters are automatically "not null", because they are= controlling parameters; a parameter of type "access T" is a controlling pa= rameter if it's for a primitive subprogram of type T where T is tagged. In Ada 95, which didn't have "not null", the rules said that parameters in = that position were required to be non-null. When "not null" was added to A= da 2005, the decision was made to allow, but not require, the "not null" on= controlling parameters, for backward compatibility. That's not the case f= or parameters in other positions, which is why you may see "not subtype con= formant" errors. "Full conformance" requires that the actual presence or absence of "not nul= l" be the same, whether or not the null exclusion is implied. However, thi= s is needed only in some contexts, such as when a subprogram is declared wi= thout a body in one place, and the same subprogram's body appears later. O= verriding doesn't require full conformance, I think; I think it only requir= es subtype conformance, although I'd have to look it up and I can't do so r= ight now. -- Adam