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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Profile mismatch? Date: Thu, 13 Mar 2014 16:35:40 +0000 Organization: A noiseless patient Spider Message-ID: References: <3d90b1df-4d18-4097-aa26-e727defd26ba@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="accbe75cb89a13856bb11e3e154f69e9"; logging-data="20879"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Fm6EaQ2waAmGP0hVJ0lsUeI510IH1178=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:uMhutRcWhNE9//cZgSp99/JA8O4= sha1:7IAhFn8lxi5F0Zzkz/h970rQFak= Xref: news.eternal-september.org comp.lang.ada:18811 Date: 2014-03-13T16:35:40+00:00 List-Id: adambeneschan@gmail.com writes: > On Thursday, March 13, 2014 5:06:40 AM UTC-7, Simon Wright wrote: >> Given the code below >> >> 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; >> >> should a compiler recognise the mismatches of the null exclusions where >> indicated? >> >> 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 >> >> not subtype conformant with operation inherited at line 42 >> type of "This" does not match >> >> 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 parameter 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 Ada 2005, the decision was made to allow, but not > require, the "not null" on controlling parameters, for backward > compatibility. That's not the case for parameters in other positions, > which is why you may see "not subtype conformant" errors. This is what GNAT is doing (I take it you don't actually mean "position"; in the first case "access T" had to be non-null in Ada 95, and in the second case it's non-controlling parameters). > "Full conformance" requires that the actual presence or absence of > "not null" be the same, whether or not the null exclusion is implied. > However, this is needed only in some contexts, such as when a > subprogram is declared without a body in one place, and the same > subprogram's body appears later. Overriding doesn't require full > conformance, I think; I think it only requires subtype conformance, > although I'd have to look it up and I can't do so right now. My code has subtype conformance, I think. Thanks!